diff options
author | Thomas Bernard <thomas@famillebernardgouriou.fr> | 2020-12-11 21:51:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-01-11 16:33:37 (GMT) |
commit | b12aec6c8daa3e087e6d0fa0441f59622251eb46 (patch) | |
tree | c42489408f58377d7d0c5a7e99cd6e3465909395 /Modules/CMakeFindBinUtils.cmake | |
parent | 06dfa5a7b6c0174bfcb4691a9aaf00809bd7271d (diff) | |
download | CMake-b12aec6c8daa3e087e6d0fa0441f59622251eb46.zip CMake-b12aec6c8daa3e087e6d0fa0441f59622251eb46.tar.gz CMake-b12aec6c8daa3e087e6d0fa0441f59622251eb46.tar.bz2 |
BinUtils: prefer bin utils matching the compiler version extension
Diffstat (limited to 'Modules/CMakeFindBinUtils.cmake')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index d81fd11..ff178f6 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -70,17 +70,18 @@ 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")) + set(_CMAKE_LINKER_NAMES "link") + set(_CMAKE_AR_NAMES "lib") + set(_CMAKE_MT_NAMES "mt") 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") + set(_CMAKE_NM_NAMES "llvm-nm" "nm") + list(APPEND _CMAKE_AR_NAMES "lib" "llvm-lib") + list(APPEND _CMAKE_MT_NAMES "mt" "llvm-mt") + list(APPEND _CMAKE_LINKER_NAMES "lld-link") + list(APPEND _CMAKE_TOOL_VARS NM) endif() - find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link 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) + list(APPEND _CMAKE_TOOL_VARS LINKER MT AR) # in all other cases search for ar, ranlib, etc. else() @@ -92,55 +93,54 @@ else() endif() if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) - set(_CMAKE_ADDITIONAL_AR_NAMES "llvm-ar") - set(_CMAKE_ADDITIONAL_RANLIB_NAMES "llvm-ranlib") - set(_CMAKE_ADDITIONAL_STRIP_NAMES "llvm-strip") if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC") - set(_CMAKE_ADDITIONAL_LINKER_NAMES "lld-link") + set(_CMAKE_LINKER_NAMES "lld-link") else() - set(_CMAKE_ADDITIONAL_LINKER_NAMES "ld.lld") + set(_CMAKE_LINKER_NAMES "ld.lld") endif() - set(_CMAKE_ADDITIONAL_NM_NAMES "llvm-nm") - set(_CMAKE_ADDITIONAL_OBJDUMP_NAMES "llvm-objdump") - set(_CMAKE_ADDITIONAL_OBJCOPY_NAMES "llvm-objcopy") - set(_CMAKE_ADDITIONAL_READELF_NAMES "llvm-readelf") - set(_CMAKE_ADDITIONAL_DLLTOOL_NAMES "llvm-dlltool") - set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line") + list(APPEND _CMAKE_AR_NAMES "llvm-ar") + list(APPEND _CMAKE_NM_NAMES "llvm-nm") + list(APPEND _CMAKE_OBJDUMP_NAMES "llvm-objdump") + list(APPEND _CMAKE_OBJCOPY_NAMES "llvm-objcopy") + list(APPEND _CMAKE_READELF_NAMES "llvm-readelf") + list(APPEND _CMAKE_DLLTOOL_NAMES "llvm-dlltool") + list(APPEND _CMAKE_ADDR2LINE_NAMES "llvm-addr2line") endif() - if(NOT CMAKE_CROSSCOMPILING AND NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "") - list(APPEND _CMAKE_ADDITIONAL_AR_NAMES "ar") - list(APPEND _CMAKE_ADDITIONAL_RANLIB_NAMES "ranlib") - list(APPEND _CMAKE_ADDITIONAL_STRIP_NAMES "strip") - list(APPEND _CMAKE_ADDITIONAL_LINKER_NAMES "ld") - list(APPEND _CMAKE_ADDITIONAL_NM_NAMES "nm") - list(APPEND _CMAKE_ADDITIONAL_OBJDUMP_NAMES "objdump") - list(APPEND _CMAKE_ADDITIONAL_OBJCOPY_NAMES "objcopy") - list(APPEND _CMAKE_ADDITIONAL_READELF_NAMES "readelf") - list(APPEND _CMAKE_ADDITIONAL_DLLTOOL_NAMES "dlltool") - list(APPEND _CMAKE_ADDITIONAL_ADDR2LINE_NAMES "addr2line") - endif() + list(APPEND _CMAKE_AR_NAMES "ar") + list(APPEND _CMAKE_RANLIB_NAMES "ranlib") + list(APPEND _CMAKE_STRIP_NAMES "strip") + list(APPEND _CMAKE_LINKER_NAMES "ld") + list(APPEND _CMAKE_NM_NAMES "nm") + list(APPEND _CMAKE_OBJDUMP_NAMES "objdump") + list(APPEND _CMAKE_OBJCOPY_NAMES "objcopy") + list(APPEND _CMAKE_READELF_NAMES "readelf") + list(APPEND _CMAKE_DLLTOOL_NAMES "dlltool") + list(APPEND _CMAKE_ADDR2LINE_NAMES "addr2line") + + list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) +endif() - find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +foreach(TOOL IN LISTS _CMAKE_TOOL_VARS) + foreach(NAME IN LISTS _CMAKE_${TOOL}_NAMES) + if(NOT _CMAKE_TOOLCHAIN_PREFIX STREQUAL "") + if(NOT _CMAKE_TOOLCHAIN_SUFFIX STREQUAL "") + list(PREPEND _CMAKE_${TOOL}_NAMES ${NAME}${_CMAKE_TOOLCHAIN_SUFFIX}) + endif() + list(PREPEND _CMAKE_${TOOL}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${NAME}) + endif() + if(NOT _CMAKE_TOOLCHAIN_SUFFIX STREQUAL "") + list(PREPEND _CMAKE_${TOOL}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${NAME}${_CMAKE_TOOLCHAIN_SUFFIX}) + endif() + endforeach() + find_program(CMAKE_${TOOL} NAMES ${_CMAKE_${TOOL}_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) +endforeach() - find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - if(NOT CMAKE_RANLIB) +if(NOT CMAKE_RANLIB) set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") - endif() - - - find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_READELF NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_DLLTOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_ADDR2LINE NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - - list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) endif() + if(CMAKE_PLATFORM_HAS_INSTALLNAME) find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) @@ -157,7 +157,7 @@ foreach(var IN LISTS _CMAKE_TOOL_VARS) if(_CMAKE_TOOL_CACHED) mark_as_advanced(CMAKE_${var}) endif() - unset(_CMAKE_ADDITIONAL_${var}_NAMES) + unset(_CMAKE_${var}_NAMES) endforeach() unset(_CMAKE_TOOL_VARS) unset(_CMAKE_TOOL_CACHED) |