mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-24 08:47:59 +00:00
Modules: use find_*(NO_CACHE)
Avoid manual cache management logic.
This commit is contained in:
@@ -112,7 +112,7 @@ macro(_cmake_find_compiler_path lang)
|
||||
# if compiler (and arguments) comes from cache then synchronize cache with updated CMAKE_<LANG>_COMPILER
|
||||
get_filename_component(_CMAKE_USER_${lang}_COMPILER_PATH "${CMAKE_${lang}_COMPILER}" PATH)
|
||||
if(NOT _CMAKE_USER_${lang}_COMPILER_PATH)
|
||||
find_program(CMAKE_${lang}_COMPILER_WITH_PATH NAMES ${CMAKE_${lang}_COMPILER})
|
||||
find_program(CMAKE_${lang}_COMPILER_WITH_PATH NO_CACHE NAMES ${CMAKE_${lang}_COMPILER})
|
||||
if(CMAKE_${lang}_COMPILER_WITH_PATH)
|
||||
set(CMAKE_${lang}_COMPILER ${CMAKE_${lang}_COMPILER_WITH_PATH})
|
||||
get_property(_CMAKE_${lang}_COMPILER_CACHED CACHE CMAKE_${lang}_COMPILER PROPERTY TYPE)
|
||||
@@ -121,7 +121,6 @@ macro(_cmake_find_compiler_path lang)
|
||||
endif()
|
||||
unset(_CMAKE_${lang}_COMPILER_CACHED)
|
||||
endif()
|
||||
unset(CMAKE_${lang}_COMPILER_WITH_PATH CACHE)
|
||||
elseif (EXISTS ${CMAKE_${lang}_COMPILER})
|
||||
get_property(_CMAKE_${lang}_COMPILER_CACHED CACHE CMAKE_${lang}_COMPILER PROPERTY TYPE)
|
||||
if(_CMAKE_${lang}_COMPILER_CACHED)
|
||||
|
||||
@@ -465,7 +465,7 @@ include(CMakeCompilerIdDetection)
|
||||
#-----------------------------------------------------------------------------
|
||||
# Function to write the compiler id source file.
|
||||
function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src)
|
||||
find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
find_file(src_in ${src}.in NO_CACHE PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
file(READ ${src_in} ID_CONTENT_IN)
|
||||
|
||||
compiler_id_detection(CMAKE_${lang}_COMPILER_ID_CONTENT ${lang}
|
||||
@@ -490,7 +490,6 @@ function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src)
|
||||
)
|
||||
endif()
|
||||
|
||||
unset(src_in CACHE)
|
||||
string(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY)
|
||||
file(WRITE ${CMAKE_${lang}_COMPILER_ID_DIR}/${src} "${ID_CONTENT_OUT}")
|
||||
endfunction()
|
||||
|
||||
@@ -76,11 +76,10 @@ else()
|
||||
# if the C compiler already had a path, reuse it for searching the CXX compiler
|
||||
get_filename_component(_CMAKE_USER_OBJC_COMPILER_PATH "${CMAKE_OBJC_COMPILER}" PATH)
|
||||
if(NOT _CMAKE_USER_OBJC_COMPILER_PATH)
|
||||
find_program(CMAKE_OBJC_COMPILER_WITH_PATH NAMES ${CMAKE_OBJC_COMPILER})
|
||||
find_program(CMAKE_OBJC_COMPILER_WITH_PATH NO_CACHE NAMES ${CMAKE_OBJC_COMPILER})
|
||||
if(CMAKE_OBJC_COMPILER_WITH_PATH)
|
||||
set(CMAKE_OBJC_COMPILER ${CMAKE_OBJC_COMPILER_WITH_PATH} CACHE STRING "Objective-C compiler" FORCE)
|
||||
endif()
|
||||
unset(CMAKE_OBJC_COMPILER_WITH_PATH CACHE)
|
||||
endif()
|
||||
endif()
|
||||
mark_as_advanced(CMAKE_OBJC_COMPILER)
|
||||
|
||||
@@ -78,11 +78,10 @@ else()
|
||||
# if the C compiler already had a path, reuse it for searching the CXX compiler
|
||||
get_filename_component(_CMAKE_USER_OBJCXX_COMPILER_PATH "${CMAKE_OBJCXX_COMPILER}" PATH)
|
||||
if(NOT _CMAKE_USER_OBJCXX_COMPILER_PATH)
|
||||
find_program(CMAKE_OBJCXX_COMPILER_WITH_PATH NAMES ${CMAKE_OBJCXX_COMPILER})
|
||||
find_program(CMAKE_OBJCXX_COMPILER_WITH_PATH NO_CACHE NAMES ${CMAKE_OBJCXX_COMPILER})
|
||||
if(CMAKE_OBJCXX_COMPILER_WITH_PATH)
|
||||
set(CMAKE_OBJCXX_COMPILER ${CMAKE_OBJCXX_COMPILER_WITH_PATH} CACHE STRING "Objective-C++ compiler" FORCE)
|
||||
endif()
|
||||
unset(CMAKE_OBJCXX_COMPILER_WITH_PATH CACHE)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
@@ -34,7 +34,7 @@ function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING)
|
||||
if(NOT _CMAKE_USER_TOOL_PATH)
|
||||
|
||||
# Find CMAKE_TOOL in the SEARCH_PATH directory by user-defined name.
|
||||
find_program(_CMAKE_TOOL_WITH_PATH NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
find_program(_CMAKE_TOOL_WITH_PATH NO_CACHE NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
|
||||
if(_CMAKE_TOOL_WITH_PATH)
|
||||
|
||||
# Overwrite CMAKE_TOOL with full path found in SEARCH_PATH.
|
||||
@@ -47,7 +47,6 @@ function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
unset(_CMAKE_TOOL_WITH_PATH CACHE)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -199,14 +199,13 @@ macro(_ipo_run_language_check language)
|
||||
PROJECT "${TRY_COMPILE_PROJECT_NAME}"
|
||||
SOURCE_DIR "${srcdir}"
|
||||
BINARY_DIR "${bindir}"
|
||||
NO_CACHE
|
||||
CMAKE_FLAGS
|
||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
|
||||
${_CMAKE_LANG_FLAGS}
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
set(_IPO_LANGUAGE_CHECK_RESULT "${_IPO_LANGUAGE_CHECK_RESULT}")
|
||||
unset(_IPO_LANGUAGE_CHECK_RESULT CACHE)
|
||||
|
||||
if(NOT _IPO_LANGUAGE_CHECK_RESULT)
|
||||
_ipo_not_supported("check failed to compile")
|
||||
|
||||
@@ -1616,6 +1616,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
|
||||
|
||||
find_program(
|
||||
_matlab_current_program
|
||||
NO_CACHE
|
||||
NAMES matlab
|
||||
${_find_matlab_options}
|
||||
DOC "Matlab main program"
|
||||
@@ -1631,14 +1632,12 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
|
||||
set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version")
|
||||
set(Matlab_OR_MCR_INTERNAL ${matlab_or_mcr} CACHE INTERNAL "Whether Matlab root contains MATLAB or MCR")
|
||||
unset(_matlab_current_program)
|
||||
unset(_matlab_current_program CACHE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# full real path for path comparison
|
||||
get_filename_component(_matlab_main_real_path_tmp "${_matlab_current_program}" REALPATH)
|
||||
unset(_matlab_current_program)
|
||||
unset(_matlab_current_program CACHE)
|
||||
|
||||
# is it the same as the previous one?
|
||||
if(_matlab_main_real_path_tmp STREQUAL Matlab_PROG_VERSION_STRING_AUTO_DETECT)
|
||||
@@ -1790,6 +1789,7 @@ function(_Matlab_find_instances_from_path matlab_roots)
|
||||
# If set by the user, this won't change.
|
||||
find_program(
|
||||
_matlab_main_tmp
|
||||
NO_CACHE
|
||||
NAMES matlab)
|
||||
|
||||
if(_matlab_main_tmp)
|
||||
@@ -1809,11 +1809,11 @@ function(_Matlab_find_instances_from_path matlab_roots)
|
||||
# We found the Matlab program
|
||||
list(APPEND _matlab_possible_roots "MATLAB" "NOTFOUND" ${_matlab_current_location})
|
||||
|
||||
# we remove this from the CACHE
|
||||
unset(_matlab_main_tmp CACHE)
|
||||
unset(_matlab_main_tmp)
|
||||
else()
|
||||
find_program(
|
||||
_matlab_mex_tmp
|
||||
NO_CACHE
|
||||
NAMES mex)
|
||||
if(_matlab_mex_tmp)
|
||||
# we then populate the list of roots, with empty version
|
||||
@@ -1832,7 +1832,7 @@ function(_Matlab_find_instances_from_path matlab_roots)
|
||||
# We found the Matlab program
|
||||
list(APPEND _matlab_possible_roots "MCR" "NOTFOUND" ${_mex_current_location})
|
||||
|
||||
unset(_matlab_mex_tmp CACHE)
|
||||
unset(_matlab_mex_tmp)
|
||||
else()
|
||||
if(MATLAB_FIND_DEBUG)
|
||||
message(STATUS "[MATLAB] mex compiler not found")
|
||||
|
||||
@@ -219,13 +219,14 @@ if(NOT ODBC_LIBRARY)
|
||||
|
||||
foreach(_lib IN LISTS _odbc_required_libs_names)
|
||||
find_library(_lib_path
|
||||
NO_CACHE
|
||||
NAMES ${_lib}
|
||||
PATHS ${_odbc_lib_paths} # system paths or collected from ODBC_CONFIG
|
||||
PATH_SUFFIXES odbc)
|
||||
if(_lib_path)
|
||||
list(APPEND _odbc_required_libs_paths ${_lib_path})
|
||||
endif()
|
||||
unset(_lib_path CACHE)
|
||||
unset(_lib_path)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -420,6 +420,7 @@ function(FortranCInterface_VERIFY)
|
||||
TARGET VerifyFortranC
|
||||
SOURCE_DIR ${FortranCInterface_SOURCE_DIR}/Verify
|
||||
BINARY_DIR ${FortranCInterface_BINARY_DIR}/Verify${lang}
|
||||
NO_CACHE
|
||||
CMAKE_FLAGS -DVERIFY_CXX=${verify_cxx}
|
||||
-DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}"
|
||||
@@ -443,7 +444,6 @@ function(FortranCInterface_VERIFY)
|
||||
message(CHECK_FAIL "Failed")
|
||||
set(FortranCInterface_VERIFIED_${lang} 0 CACHE INTERNAL "Fortran/${lang} compatibility")
|
||||
endif()
|
||||
unset(FortranCInterface_VERIFY_${lang}_COMPILED CACHE)
|
||||
endif()
|
||||
|
||||
# Error if compilers are incompatible.
|
||||
|
||||
@@ -45,6 +45,7 @@ try_compile(FortranCInterface_COMPILED
|
||||
TARGET FortranCInterface
|
||||
SOURCE_DIR ${FortranCInterface_SOURCE_DIR}
|
||||
BINARY_DIR ${FortranCInterface_BINARY_DIR}
|
||||
NO_CACHE
|
||||
LOG_DESCRIPTION "Fortran/C interface test project"
|
||||
CMAKE_FLAGS
|
||||
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}"
|
||||
@@ -54,8 +55,6 @@ try_compile(FortranCInterface_COMPILED
|
||||
${_FortranCInterface_OSX_ARCH}
|
||||
${_FortranCInterface_EXE_LINKER_FLAGS}
|
||||
)
|
||||
set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED})
|
||||
unset(FortranCInterface_COMPILED CACHE)
|
||||
unset(_FortranCInterface_EXE_LINKER_FLAGS)
|
||||
unset(_FortranCInterface_OSX_ARCH)
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ macro(cmake_nvcc_parse_implicit_info lang lang_var_)
|
||||
else()
|
||||
string(APPEND _nvcc_log " extracted link launcher name: [${_nvcc_host_link_launcher}]\n")
|
||||
find_program(_nvcc_find_host_link_launcher
|
||||
NO_CACHE
|
||||
NAMES ${_nvcc_host_link_launcher}
|
||||
PATHS ${_nvcc_path} NO_DEFAULT_PATH)
|
||||
find_program(_nvcc_find_host_link_launcher
|
||||
@@ -119,7 +120,7 @@ macro(cmake_nvcc_parse_implicit_info lang lang_var_)
|
||||
string(APPEND _nvcc_log " could not find link launcher absolute path\n")
|
||||
set(CMAKE_${lang}_HOST_LINK_LAUNCHER "${_nvcc_host_link_launcher}")
|
||||
endif()
|
||||
unset(_nvcc_find_host_link_launcher CACHE)
|
||||
unset(_nvcc_find_host_link_launcher)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ macro(_record_compiler_features lang compile_flags feature_list)
|
||||
LINK_LIBRARIES "${compile_flags_for_link}"
|
||||
COPY_FILE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin"
|
||||
COPY_FILE_ERROR _copy_error
|
||||
NO_CACHE
|
||||
__CMAKE_INTERNAL FEATURE_TESTING
|
||||
)
|
||||
if(NOT CMAKE_${lang}_FEATURE_TEST)
|
||||
@@ -47,7 +48,7 @@ macro(_record_compiler_features lang compile_flags feature_list)
|
||||
else()
|
||||
set(_result 0)
|
||||
endif()
|
||||
unset(CMAKE_${lang}_FEATURE_TEST CACHE)
|
||||
unset(CMAKE_${lang}_FEATURE_TEST)
|
||||
unset(compile_flags_for_link)
|
||||
|
||||
if (_result EQUAL 0)
|
||||
|
||||
@@ -207,19 +207,19 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
|
||||
if(NOT CMAKE_RC_COMPILER_INIT)
|
||||
# Check if rc is already in the path
|
||||
# This may happen in cases where the user is already in a visual studio environment when CMake is invoked
|
||||
find_program(__RC_COMPILER_PATH NAMES rc)
|
||||
find_program(__RC_COMPILER_PATH NO_CACHE NAMES rc)
|
||||
|
||||
# Default to rc if it's available, otherwise fall back to llvm-rc
|
||||
if(__RC_COMPILER_PATH)
|
||||
set(CMAKE_RC_COMPILER_INIT rc)
|
||||
else()
|
||||
find_program(__RC_COMPILER_PATH NAMES llvm-rc)
|
||||
find_program(__RC_COMPILER_PATH NO_CACHE NAMES llvm-rc)
|
||||
if(__RC_COMPILER_PATH)
|
||||
set(CMAKE_RC_COMPILER_INIT llvm-rc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(__RC_COMPILER_PATH CACHE)
|
||||
unset(__RC_COMPILER_PATH)
|
||||
endif()
|
||||
|
||||
if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"
|
||||
|
||||
@@ -63,7 +63,7 @@ events:(
|
||||
]*)+
|
||||
buildResult:
|
||||
variable: "CMAKE_C_FEATURE_TEST"
|
||||
cached: true
|
||||
cached: false
|
||||
stdout: \|.*
|
||||
exitCode: 0)*
|
||||
-
|
||||
|
||||
@@ -61,7 +61,7 @@ events:(
|
||||
]*)+
|
||||
buildResult:
|
||||
variable: "CMAKE_C_FEATURE_TEST"
|
||||
cached: true
|
||||
cached: false
|
||||
stdout: \|.*
|
||||
exitCode: 0)*
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user