summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2020-09-23 23:58:39 (GMT)
committerBrad King <brad.king@kitware.com>2020-09-24 19:37:24 (GMT)
commitf5d3da091b8e5952f8e880afbd09ee2f18e8ea7f (patch)
tree6cbe0792ac937cde4ecd40d0a731124028ebe40e
parent177fc020731bcee747295573c92cd0f7ca200e53 (diff)
downloadCMake-f5d3da091b8e5952f8e880afbd09ee2f18e8ea7f.zip
CMake-f5d3da091b8e5952f8e880afbd09ee2f18e8ea7f.tar.gz
CMake-f5d3da091b8e5952f8e880afbd09ee2f18e8ea7f.tar.bz2
Clang: Look for llvm-lib when using MSVC-like front-end
In commit 55196a1440 (MSVC: Use 'lib' instead of 'link /lib' to create static libraries, 2020-01-10, v3.18.0-rc1~625^2) we changed CMake to use lib instead of `link /lib` to create static libraries, but it didn't search for `llvm-lib`. If you have `llvm-lib` but not `lib` (e.g. when cross-compiling), when `CMakeFindBinutils` is invoked for the `C` and `CXX` languages, `CMAKE_AR` is not found. When it's subsequently invoked for the ASM language, `CMAKE_ASM_SIMULATE_ID` and `CMAKE_ASM_COMPILER_FRONTEND_VARIANT` are not set (because `CMakeDetermineASMCompiler` doesn't call `CMAKE_DETERMINE_COMPILER_ID`, which sets those variables), so we go down the non-MSVC conditional and set `CMAKE_AR` to a GNU-style `ar`, which of course does not understand lib flags. Explicitly search for `llvm-lib` to avoid this situation.
-rw-r--r--Modules/CMakeFindBinUtils.cmake3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index b2004f1..73d57f0 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -72,10 +72,11 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")
find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm llvm-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
set(_CMAKE_ADDITIONAL_LINKER_NAMES "lld-link")
+ set(_CMAKE_ADDITIONAL_AR_NAMES "llvm-lib")
endif()
find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_AR NAMES lib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_AR NAMES ${_CMAKE_ADDITIONAL_AR_NAMES} lib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
list(APPEND _CMAKE_TOOL_VARS LINKER MT)