diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 4ce45af..bfa9491 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -70,14 +70,17 @@ 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) endif() @@ -92,50 +95,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) |