diff options
author | Zsolt Parragi <zsolt.parragi@cancellar.hu> | 2019-07-11 14:55:19 (GMT) |
---|---|---|
committer | Zsolt Parragi <zsolt.parragi@cancellar.hu> | 2019-08-27 18:19:29 (GMT) |
commit | 079b8e29168dc081f37f79f3577a5c0690bb7051 (patch) | |
tree | b991243e9d98af89d4978f669025df8c5cc66182 /Modules/CMakeFindBinUtils.cmake | |
parent | 6e3655db2cc8202424e54bdde83e4240eb680cc3 (diff) | |
download | CMake-079b8e29168dc081f37f79f3577a5c0690bb7051.zip CMake-079b8e29168dc081f37f79f3577a5c0690bb7051.tar.gz CMake-079b8e29168dc081f37f79f3577a5c0690bb7051.tar.bz2 |
Clang: prefer lld-link over link.exe
Objects compiled with -flto can only be linked with the llvm linker.
Before this change, clang-cl only supperted IPO with manual linker
selection.
Diffstat (limited to 'Modules/CMakeFindBinUtils.cmake')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 773ee53..01f9dae 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -69,7 +69,12 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND OR (CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) - find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + 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") + endif() + + find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS LINKER MT) @@ -115,6 +120,17 @@ else() list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) + + unset(_CMAKE_ADDITIONAL_AR_NAMES) + unset(_CMAKE_ADDITIONAL_RANLIB_NAMES) + unset(_CMAKE_ADDITIONAL_STRIP_NAMES) + unset(_CMAKE_ADDITIONAL_LINKER_NAMES) + unset(_CMAKE_ADDITIONAL_NM_NAMES) + unset(_CMAKE_ADDITIONAL_OBJDUMP_NAMES) + unset(_CMAKE_ADDITIONAL_OBJCOPY_NAMES) + unset(_CMAKE_ADDITIONAL_READELF_NAMES) + unset(_CMAKE_ADDITIONAL_DLLTOOL_NAMES) + unset(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES) endif() if(CMAKE_PLATFORM_HAS_INSTALLNAME) |