diff options
author | Thomas Bernard <tbernard@go-engineering.de> | 2020-08-26 19:40:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-08-27 16:25:20 (GMT) |
commit | 7e72fe2ec97d97246865590e88b226515a28d916 (patch) | |
tree | 7e4354e45c1422f67b1c284a58442c8d69b5dc56 /Modules/Platform/Windows-Clang.cmake | |
parent | 5e212cafba0f2266510841eea3f5c7b79fde9449 (diff) | |
download | CMake-7e72fe2ec97d97246865590e88b226515a28d916.zip CMake-7e72fe2ec97d97246865590e88b226515a28d916.tar.gz CMake-7e72fe2ec97d97246865590e88b226515a28d916.tar.bz2 |
llvm-rc: Refactor the preprocessing logic
Diffstat (limited to 'Modules/Platform/Windows-Clang.cmake')
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 7a75004..88c9a89 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -97,6 +97,27 @@ macro(__windows_compiler_clang_gnu lang) enable_language(RC) endmacro() +macro(__enable_llvm_rc_preprocessing clang_option_prefix) + # Feed the preprocessed rc file to llvm-rc + if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc" OR CMAKE_RC_COMPILER MATCHES "llvm-rc") + if(DEFINED CMAKE_C_COMPILER_ID) + set(CMAKE_RC_PREPROCESSOR CMAKE_C_COMPILER) + elseif(DEFINED CMAKE_CXX_COMPILER_ID) + set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) + endif() + if(DEFINED CMAKE_RC_PREPROCESSOR) + set(CMAKE_DEPFILE_FLAGS_RC "${clang_option_prefix}-MD ${clang_option_prefix}-MF ${clang_option_prefix}<DEPFILE>") + set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") + if(CMAKE_GENERATOR MATCHES "Ninja") + set(CMAKE_NINJA_CMCLDEPS_RC 0) + set(CMAKE_NINJA_DEP_TYPE_RC gcc) + endif() + unset(CMAKE_RC_PREPROCESSOR) + endif() + endif() +endmacro() + + if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") @@ -124,7 +145,10 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if(__RC_COMPILER_PATH) set(CMAKE_RC_COMPILER_INIT rc) else() - set(CMAKE_RC_COMPILER_INIT llvm-rc) + find_program(__RC_COMPILER_PATH NAMES llvm-rc) + if(__RC_COMPILER_PATH) + set(CMAKE_RC_COMPILER_INIT llvm-rc) + endif() endif() unset(__RC_COMPILER_PATH CACHE) @@ -132,25 +156,8 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) include(Platform/Windows-MSVC) - - # Feed the preprocessed rc file to llvm-rc - if(CMAKE_RC_COMPILER_INIT MATCHES "llvm-rc") - if(DEFINED CMAKE_C_COMPILER_ID) - set(CMAKE_RC_PREPROCESSOR CMAKE_C_COMPILER) - elseif(DEFINED CMAKE_CXX_COMPILER_ID) - set(CMAKE_RC_PREPROCESSOR CMAKE_CXX_COMPILER) - endif() - if(DEFINED CMAKE_RC_PREPROCESSOR) - set(CMAKE_DEPFILE_FLAGS_RC "-clang:-MD -clang:-MF -clang:<DEPFILE>") - set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_COMMAND> -E cmake_llvm_rc <SOURCE> <OBJECT>.pp <${CMAKE_RC_PREPROCESSOR}> <DEFINES> -DRC_INVOKED <INCLUDES> <FLAGS> -E -- <SOURCE> ++ <CMAKE_RC_COMPILER> <DEFINES> -I <SOURCE_DIR> <INCLUDES> /fo <OBJECT> <OBJECT>.pp") - if(CMAKE_GENERATOR STREQUAL "Ninja") - set(CMAKE_NINJA_CMCLDEPS_RC 0) - set(CMAKE_NINJA_DEP_TYPE_RC gcc) - endif() - unset(CMAKE_RC_PREPROCESSOR) - endif() - endif() - + # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage + __enable_llvm_rc_preprocessing("-clang:") macro(__windows_compiler_clang lang) set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) |