Use the CMAKE_CHECKS_CACHE_FILE variable, if present, to set the

location of the checks cache file. Use the default
BINARY_DIR/cmake_checks_cache.txt by default.
This commit is contained in:
Pedro Navarro
2018-12-19 14:03:33 -08:00
parent 272b977d54
commit f860440775
12 changed files with 21 additions and 19 deletions

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake)
macro(check_c_compiler_flag flag variable) macro(check_c_compiler_flag flag variable)
_check_c_compiler_flag("${flag}" ${variable}) _check_c_compiler_flag("${flag}" ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n")
endmacro() endmacro()

View File

@@ -33,5 +33,5 @@ macro(check_c_source_compiles source variable)
else() else()
_check_c_source_compiles("${source}" ${variable} "${ARGN}") _check_c_source_compiles("${source}" ${variable} "${ARGN}")
endif() endif()
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n")
endmacro() endmacro()

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckCXXCompilerFlag.cmake)
macro(check_cxx_compiler_flag flag variable) macro(check_cxx_compiler_flag flag variable)
_check_cxx_compiler_flag("${flag}" ${variable}) _check_cxx_compiler_flag("${flag}" ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n")
endmacro() endmacro()

View File

@@ -33,5 +33,5 @@ macro(check_cxx_source_compiles source variable)
else() else()
_check_cxx_source_compiles("${source}" ${variable} "${ARGN}") _check_cxx_source_compiles("${source}" ${variable} "${ARGN}")
endif() endif()
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Test ${variable}\")\n")
endmacro() endmacro()

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
macro(check_function_exists function variable) macro(check_function_exists function variable)
_check_function_exists(${function} ${variable}) _check_function_exists(${function} ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have function ${function}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have function ${function}\")\n")
endmacro() endmacro()

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
macro(check_include_file header variable) macro(check_include_file header variable)
_check_include_file(${header} ${variable}) _check_include_file(${header} ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have include ${header}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have include ${header}\")\n")
endmacro() endmacro()

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
macro(check_include_file_cxx header variable) macro(check_include_file_cxx header variable)
_check_include_file_cxx(${header} ${variable}) _check_include_file_cxx(${header} ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have include ${header}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have include ${header}\")\n")
endmacro() endmacro()

View File

@@ -33,5 +33,5 @@ macro(check_include_files headers variable)
else() else()
_check_include_files("${headers}" ${variable} "${ARGN}") _check_include_files("${headers}" ${variable} "${ARGN}")
endif() endif()
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have include ${headers}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have include ${headers}\")\n")
endmacro() endmacro()

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
macro(check_library_exists library function location variable) macro(check_library_exists library function location variable)
_check_library_exists("${library}" ${function} "${location}" ${variable}) _check_library_exists("${library}" ${function} "${location}" ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have library ${library}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have library ${library}\")\n")
endmacro() endmacro()

View File

@@ -29,5 +29,5 @@ include(${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
macro(check_symbol_exists symbol header variable) macro(check_symbol_exists symbol header variable)
_check_symbol_exists(${symbol} "${header}" ${variable}) _check_symbol_exists(${symbol} "${header}" ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have symbol ${symbol}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"Have symbol ${symbol}\")\n")
endmacro() endmacro()

View File

@@ -29,10 +29,10 @@ include(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
macro(check_type_size type variable) macro(check_type_size type variable)
_check_type_size(${type} ${variable}) _check_type_size(${type} ${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(HAVE_${variable} \"${HAVE_${variable}}\" CACHE INTERNAL \"Result of TRY_COMPILE\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(HAVE_${variable} \"${HAVE_${variable}}\" CACHE INTERNAL \"Result of TRY_COMPILE\")\n")
if(HAVE_${variable}) if(HAVE_${variable})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"${${variable}}\" CACHE INTERNAL \"CHECK_TYPE_SIZE: sizeof(${type})\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"${${variable}}\" CACHE INTERNAL \"CHECK_TYPE_SIZE: sizeof(${type})\")\n")
else() else()
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${variable} \"\" CACHE INTERNAL \"CHECK_TYPE_SIZE: ${type} unknown\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${variable} \"\" CACHE INTERNAL \"CHECK_TYPE_SIZE: ${type} unknown\")\n")
endif() endif()
endmacro() endmacro()

View File

@@ -24,9 +24,11 @@ include_guard(GLOBAL)
cmake_minimum_required(VERSION 3.11) cmake_minimum_required(VERSION 3.11)
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "###############################################################\n") set(CMAKE_CHECKS_CACHE_FILE "${CMAKE_BINARY_DIR}/cmake_checks_cache.txt" CACHE FILEPATH "CMake checks cache file")
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "# Dump of all cache variables that started with CMAKE_*\n")
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "###############################################################\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "###############################################################\n")
file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "# Dump of all cache variables that started with CMAKE_*\n")
file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "###############################################################\n")
get_cmake_property(_cachedVariableNames CACHE_VARIABLES) get_cmake_property(_cachedVariableNames CACHE_VARIABLES)
list(FILTER _cachedVariableNames INCLUDE REGEX "^CMAKE_.*$") list(FILTER _cachedVariableNames INCLUDE REGEX "^CMAKE_.*$")
@@ -35,11 +37,11 @@ foreach (_cacheVariable ${_cachedVariableNames})
get_property(_advanced CACHE "${_cacheVariable}" PROPERTY ADVANCED) get_property(_advanced CACHE "${_cacheVariable}" PROPERTY ADVANCED)
get_property(_help_string CACHE "${_cacheVariable}" PROPERTY HELPSTRING) get_property(_help_string CACHE "${_cacheVariable}" PROPERTY HELPSTRING)
if (NOT "${_type}" STREQUAL "UNINITIALIZED" AND NOT "${_type}" STREQUAL "STATIC") if (NOT "${_type}" STREQUAL "UNINITIALIZED" AND NOT "${_type}" STREQUAL "STATIC")
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "set(${_cacheVariable} \"${${_cacheVariable}}\" CACHE ${_type} \"${_help_string}\")\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "set(${_cacheVariable} \"${${_cacheVariable}}\" CACHE ${_type} \"${_help_string}\")\n")
if (${_advanced}) if (${_advanced})
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "mark_as_advanced(${_cacheVariable})\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "mark_as_advanced(${_cacheVariable})\n")
endif() endif()
endif() endif()
endforeach() endforeach()
file(APPEND ${CMAKE_BINARY_DIR}/cmake_checks_cache.txt "###############################################################\n") file(APPEND ${CMAKE_CHECKS_CACHE_FILE} "###############################################################\n")