diff options
author | Brad King <brad.king@kitware.com> | 2018-09-05 18:57:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-05 19:03:02 (GMT) |
commit | 53bae4cc5e654266fa7f476d6e7e2b27217c8c38 (patch) | |
tree | c3bda2fec3f551862d154695c7c74a70779d6bd3 /Modules/CMakeFindBinUtils.cmake | |
parent | 182522a209331cd1d221420972ed6b200918f6e6 (diff) | |
download | CMake-53bae4cc5e654266fa7f476d6e7e2b27217c8c38.zip CMake-53bae4cc5e654266fa7f476d6e7e2b27217c8c38.tar.gz CMake-53bae4cc5e654266fa7f476d6e7e2b27217c8c38.tar.bz2 |
CMakeFindBinUtils: Fix use with non-cached tool settings
If a project or toolchain file hard-codes a tool location such as
`CMAKE_LINKER` with a plain `set()` then the value will be stored
in compiler information files but not cached. If the value is
not cached then we should not mark it as advanced because doing
so will initialize an empty cache entry.
Fixes: #18315
Diffstat (limited to 'Modules/CMakeFindBinUtils.cmake')
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 1b6823c..830639d 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -38,6 +38,8 @@ if(CMAKE_LINKER) endif() endif() +set(_CMAKE_TOOL_VARS "") + # 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" @@ -47,7 +49,7 @@ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - mark_as_advanced(CMAKE_LINKER) + list(APPEND _CMAKE_TOOL_VARS CMAKE_LINKER) # in all other cases search for ar, ranlib, etc. else() @@ -70,7 +72,7 @@ else() find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - mark_as_advanced(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) + list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) endif() @@ -81,5 +83,15 @@ if(CMAKE_PLATFORM_HAS_INSTALLNAME) message(FATAL_ERROR "Could not find install_name_tool, please check your installation.") endif() - mark_as_advanced(CMAKE_INSTALL_NAME_TOOL) + list(APPEND _CMAKE_TOOL_VARS CMAKE_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) + if(_CMAKE_TOOL_CACHED) + mark_as_advanced(${var}) + endif() +endforeach() +unset(_CMAKE_TOOL_VARS) +unset(_CMAKE_TOOL_CACHED) |