Sfoglia il codice sorgente

CMakeFindBinUtils: Rename and unset variables for additional names

use the name pattern `_CMAKE_ADDITIONAL_<PROGRAM_NAME>_NAMES`,
and unset those variables at the end of the function
Norbert Lange 6 anni fa
parent
commit
3a82ef78eb
1 ha cambiato i file con 14 aggiunte e 13 eliminazioni
  1. 14 13
      Modules/CMakeFindBinUtils.cmake

+ 14 - 13
Modules/CMakeFindBinUtils.cmake

@@ -72,7 +72,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
   find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
   find_program(CMAKE_MT     NAMES mt   HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
 
-  list(APPEND _CMAKE_TOOL_VARS CMAKE_LINKER CMAKE_MT)
+  list(APPEND _CMAKE_TOOL_VARS LINKER MT)
 
 # in all other cases search for ar, ranlib, etc.
 else()
@@ -84,27 +84,27 @@ else()
   endif()
 
   if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang)
-    set(LLVM_OBJDUMP "llvm-objdump")
-    set(LLVM_LLD "ld.lld")
-    set(LLVM_RANLIB "llvm-ranlib")
-    set(LLVM_AR "llvm-ar")
+    set(_CMAKE_ADDITIONAL_OBJDUMP_NAMES "llvm-objdump")
+    set(_CMAKE_ADDITIONAL_LINKER_NAMES "ld.lld")
+    set(_CMAKE_ADDITIONAL_RANLIB_NAMES "llvm-ranlib")
+    set(_CMAKE_ADDITIONAL_AR_NAMES "llvm-ar")
   endif()
 
-  find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${LLVM_AR} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+  find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
 
-  find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${LLVM_RANLIB} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+  find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
   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} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
-  find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${LLVM_LLD} 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 HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
-  find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${LLVM_OBJDUMP} 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 HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
 
-  list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
+  list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY)
 
 endif()
 
@@ -115,15 +115,16 @@ if(CMAKE_PLATFORM_HAS_INSTALLNAME)
     message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
   endif()
 
-  list(APPEND _CMAKE_TOOL_VARS CMAKE_INSTALL_NAME_TOOL)
+  list(APPEND _CMAKE_TOOL_VARS INSTALL_NAME_TOOL)
 endif()
 
 # Mark any tool cache entries as advanced.
 foreach(var IN LISTS _CMAKE_TOOL_VARS)
-  get_property(_CMAKE_TOOL_CACHED CACHE ${var} PROPERTY TYPE)
+  get_property(_CMAKE_TOOL_CACHED CACHE CMAKE_${var} PROPERTY TYPE)
   if(_CMAKE_TOOL_CACHED)
-    mark_as_advanced(${var})
+    mark_as_advanced(CMAKE_${var})
   endif()
+  unset(_CMAKE_ADDITIONAL_${var}_NAMES)
 endforeach()
 unset(_CMAKE_TOOL_VARS)
 unset(_CMAKE_TOOL_CACHED)