summaryrefslogtreecommitdiffstats
path: root/Modules/Platform
diff options
context:
space:
mode:
authorGregory Mitrano <gregory.mitrano@gmail.com>2019-08-13 04:00:06 (GMT)
committerGregory Mitrano <gregory.mitrano@gmail.com>2019-08-14 04:20:39 (GMT)
commitcea253a38bb33beb64c7b36c7c75929453ec8749 (patch)
tree7ce932483ea1d11091cc51ce254330d2b628d221 /Modules/Platform
parent42c993742d8f92c54043363909803a2242f111d3 (diff)
downloadCMake-cea253a38bb33beb64c7b36c7c75929453ec8749.zip
CMake-cea253a38bb33beb64c7b36c7c75929453ec8749.tar.gz
CMake-cea253a38bb33beb64c7b36c7c75929453ec8749.tar.bz2
Clang: Fall back to llvm-rc when rc is unavailable
This change modifies how CMAKE_RC_COMPILER is configured to improve the out-of-box experience for developers using Clang on Windows. The previous behavior was to require the user to explicitly specify the resource compiler when CMake was called. The new behavior is to automatically attempt to locate the MSVC rc binary and use that if it's found. If rc is not available, CMake will now fall back to Clang's llvm-rc binary. With this change in place, trivial C/C++ programs can be generated with Ninja and Clang on Windows without running into errors about a missing resource compiler. Fixes: #19318
Diffstat (limited to 'Modules/Platform')
-rw-r--r--Modules/Platform/Windows-Clang.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index b317da6..728e0b9 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -99,6 +99,21 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
"or clang-cl as both C and C++ compilers.")
endif()
+ if(NOT CMAKE_RC_COMPILER_INIT)
+ # Check if rc is already in the path
+ # This may happen in cases where the user is already in a visual studio environment when CMake is invoked
+ find_program(__RC_COMPILER_PATH NAMES rc)
+
+ # Default to rc if it's available, otherwise fall back to llvm-rc
+ if(__RC_COMPILER_PATH)
+ set(CMAKE_RC_COMPILER_INIT rc)
+ else()
+ set(CMAKE_RC_COMPILER_INIT llvm-rc)
+ endif()
+
+ unset(__RC_COMPILER_PATH CACHE)
+ endif()
+
if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" )
include(Platform/Windows-MSVC)