diff options
author | Brad King <brad.king@kitware.com> | 2018-02-21 15:43:03 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-02-21 15:43:09 (GMT) |
commit | 283562624c6a29ce0bad9beca81571f4691ca29d (patch) | |
tree | d43fa7a19986e176520044502172ab32440419e4 /Modules | |
parent | 4e6f94d49ca591ff90ead5f00df71b22f97241e6 (diff) | |
parent | e936b6bb5a7e930ac030645a412021383be408d7 (diff) | |
download | CMake-283562624c6a29ce0bad9beca81571f4691ca29d.zip CMake-283562624c6a29ce0bad9beca81571f4691ca29d.tar.gz CMake-283562624c6a29ce0bad9beca81571f4691ca29d.tar.bz2 |
Merge topic 'find-linker'
e936b6bb CMakeFindBinUtils: Find linker in PATH
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1720
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index ece0547..1b6823c 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -19,6 +19,25 @@ # on UNIX, cygwin and mingw +if(CMAKE_LINKER) + # we only get here if CMAKE_LINKER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # find the linker in the PATH if necessary + get_filename_component(_CMAKE_USER_LINKER_PATH "${CMAKE_LINKER}" PATH) + if(NOT _CMAKE_USER_LINKER_PATH) + find_program(CMAKE_LINKER_WITH_PATH NAMES ${CMAKE_LINKER} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + if(CMAKE_LINKER_WITH_PATH) + set(CMAKE_LINKER ${CMAKE_LINKER_WITH_PATH}) + get_property(_CMAKE_LINKER_CACHED CACHE CMAKE_LINKER PROPERTY TYPE) + if(_CMAKE_LINKER_CACHED) + set(CMAKE_LINKER "${CMAKE_LINKER}" CACHE STRING "Default Linker" FORCE) + endif() + unset(_CMAKE_LINKER_CACHED) + endif() + unset(CMAKE_LINKER_WITH_PATH CACHE) + endif() +endif() + # if it's the MS C/CXX compiler, search for link if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC" |