diff options
author | Brad King <brad.king@kitware.com> | 2021-05-28 16:23:56 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-05-28 16:24:10 (GMT) |
commit | 1143213e380e692ef88d560b839eccfa10babd75 (patch) | |
tree | f0388ac43106c0edd90c56bfc0b4f5f67487a6a2 /Modules | |
parent | 42305f7d9a3deb4a54669cd8c165c43511651120 (diff) | |
parent | 047585edc62fc4223a77a2c587a2ac795c91718f (diff) | |
download | CMake-1143213e380e692ef88d560b839eccfa10babd75.zip CMake-1143213e380e692ef88d560b839eccfa10babd75.tar.gz CMake-1143213e380e692ef88d560b839eccfa10babd75.tar.bz2 |
Merge topic 'binutils-consistency'
047585edc6 BinUtils: Find linker and librarian for Intel compilers on Windows
995f5b4e7b BinUtils: Find linker and librarian for OpenWatcom
cf82300a63 BinUtils: Clarify search logic and make it more consistent
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6164
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 83 | ||||
-rw-r--r-- | Modules/Compiler/OpenWatcom.cmake | 10 | ||||
-rw-r--r-- | Modules/Platform/Windows-Intel.cmake | 4 |
3 files changed, 54 insertions, 43 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 4ce45af..9dac4a9 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -70,19 +70,30 @@ 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")) + # Start with the canonical names. set(_CMAKE_LINKER_NAMES "link") set(_CMAKE_AR_NAMES "lib") set(_CMAKE_MT_NAMES "mt") + + # Prepend toolchain-specific names. if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang") 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(PREPEND _CMAKE_AR_NAMES "llvm-lib") + list(PREPEND _CMAKE_MT_NAMES "llvm-mt") + list(PREPEND _CMAKE_LINKER_NAMES "lld-link") list(APPEND _CMAKE_TOOL_VARS NM) + elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIntel") + list(PREPEND _CMAKE_AR_NAMES "xilib") + list(PREPEND _CMAKE_LINKER_NAMES "xilink") endif() list(APPEND _CMAKE_TOOL_VARS LINKER MT AR) +elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^x(Open)?Watcom$") + set(_CMAKE_LINKER_NAMES "wlink") + set(_CMAKE_AR_NAMES "wlib") + list(APPEND _CMAKE_TOOL_VARS LINKER AR) + # in all other cases search for ar, ranlib, etc. else() if(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN) @@ -92,50 +103,54 @@ else() set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin) endif() + # Start with the canonical names. + set(_CMAKE_AR_NAMES "ar") + set(_CMAKE_RANLIB_NAMES "ranlib") + set(_CMAKE_STRIP_NAMES "strip") + set(_CMAKE_LINKER_NAMES "ld") + set(_CMAKE_NM_NAMES "nm") + set(_CMAKE_OBJDUMP_NAMES "objdump") + set(_CMAKE_OBJCOPY_NAMES "objcopy") + set(_CMAKE_READELF_NAMES "readelf") + set(_CMAKE_DLLTOOL_NAMES "dlltool") + set(_CMAKE_ADDR2LINE_NAMES "addr2line") + + # Prepend toolchain-specific names. if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC") set(_CMAKE_LINKER_NAMES "lld-link") else() set(_CMAKE_LINKER_NAMES "ld.lld") endif() - list(APPEND _CMAKE_AR_NAMES "llvm-ar") - list(APPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") - list(APPEND _CMAKE_STRIP_NAMES "llvm-strip") - 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") + list(PREPEND _CMAKE_AR_NAMES "llvm-ar") + list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") + list(PREPEND _CMAKE_STRIP_NAMES "llvm-strip") + list(PREPEND _CMAKE_NM_NAMES "llvm-nm") + list(PREPEND _CMAKE_OBJDUMP_NAMES "llvm-objdump") + list(PREPEND _CMAKE_OBJCOPY_NAMES "llvm-objcopy") + list(PREPEND _CMAKE_READELF_NAMES "llvm-readelf") + list(PREPEND _CMAKE_DLLTOOL_NAMES "llvm-dlltool") + list(PREPEND _CMAKE_ADDR2LINE_NAMES "llvm-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) + list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) endif() foreach(_CMAKE_TOOL IN LISTS _CMAKE_TOOL_VARS) + # Build the final list of prefixed/suffixed names. + set(_CMAKE_${_CMAKE_TOOL}_FIND_NAMES "") foreach(_CMAKE_TOOL_NAME IN LISTS _CMAKE_${_CMAKE_TOOL}_NAMES) - if(NOT _CMAKE_TOOLCHAIN_PREFIX STREQUAL "") - if(NOT _CMAKE_TOOLCHAIN_SUFFIX STREQUAL "") - list(PREPEND _CMAKE_${_CMAKE_TOOL}_NAMES ${_CMAKE_TOOL_NAME}${_CMAKE_TOOLCHAIN_SUFFIX}) - endif() - list(PREPEND _CMAKE_${_CMAKE_TOOL}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${_CMAKE_TOOL_NAME}) - endif() - if(NOT _CMAKE_TOOLCHAIN_SUFFIX STREQUAL "") - list(PREPEND _CMAKE_${_CMAKE_TOOL}_NAMES ${_CMAKE_TOOLCHAIN_PREFIX}${_CMAKE_TOOL_NAME}${_CMAKE_TOOLCHAIN_SUFFIX}) - endif() + list(APPEND _CMAKE_${_CMAKE_TOOL}_FIND_NAMES + ${_CMAKE_TOOLCHAIN_PREFIX}${_CMAKE_TOOL_NAME}${_CMAKE_TOOLCHAIN_SUFFIX} + ${_CMAKE_TOOLCHAIN_PREFIX}${_CMAKE_TOOL_NAME} + ${_CMAKE_TOOL_NAME}${_CMAKE_TOOLCHAIN_SUFFIX} + ${_CMAKE_TOOL_NAME} + ) endforeach() - find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + list(REMOVE_DUPLICATES _CMAKE_${_CMAKE_TOOL}_FIND_NAMES) + + find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_FIND_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + unset(_CMAKE_${_CMAKE_TOOL}_FIND_NAMES) endforeach() if(NOT CMAKE_RANLIB) diff --git a/Modules/Compiler/OpenWatcom.cmake b/Modules/Compiler/OpenWatcom.cmake index a962513..ec36908 100644 --- a/Modules/Compiler/OpenWatcom.cmake +++ b/Modules/Compiler/OpenWatcom.cmake @@ -43,13 +43,13 @@ endforeach() # C create import library set(CMAKE_C_CREATE_IMPORT_LIBRARY - "wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>") + "<CMAKE_AR> -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>") # C++ create import library set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) # C link a object files into an executable file set(CMAKE_C_LINK_EXECUTABLE - "wlink ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES>") + "<CMAKE_LINKER> ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES>") # C++ link a object files into an executable file set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) @@ -69,19 +69,19 @@ set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE # C create a shared library set(CMAKE_C_CREATE_SHARED_LIBRARY - "wlink ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES>") + "<CMAKE_LINKER> ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES>") # C++ create a shared library set(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_LIBRARY}) # C create a shared module set(CMAKE_C_CREATE_SHARED_MODULE - "wlink ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES>") + "<CMAKE_LINKER> ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES>") # C++ create a shared module set(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_MODULE}) # C create a static library set(CMAKE_C_CREATE_STATIC_LIBRARY - "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ") + "<CMAKE_AR> ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ") # C++ create a static library set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY}) diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake index 01f8dd0..26e0cde 100644 --- a/Modules/Platform/Windows-Intel.cmake +++ b/Modules/Platform/Windows-Intel.cmake @@ -25,8 +25,4 @@ endif() include(Platform/Windows-MSVC) macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - string(REPLACE "<CMAKE_AR>" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") - foreach(rule CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) - string(REPLACE "<CMAKE_LINKER>" "xilink" CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}") - endforeach() endmacro() |