summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorZhong Ruoyu <zhongruoyu@outlook.com>2022-11-28 16:08:24 (GMT)
committerBrad King <brad.king@kitware.com>2022-11-28 21:53:12 (GMT)
commitf6b99c5087e1dfae29efc5146508e8b8b8b59b29 (patch)
treeb9e14388d2b0767dcc41ea64e4bee3f37cc9b921 /Modules
parent90907c8ff96ff07f0dafc1f4904d25b1e10f014b (diff)
downloadCMake-f6b99c5087e1dfae29efc5146508e8b8b8b59b29.zip
CMake-f6b99c5087e1dfae29efc5146508e8b8b8b59b29.tar.gz
CMake-f6b99c5087e1dfae29efc5146508e8b8b8b59b29.tar.bz2
Check*: Restore support for arbitrary result variable names
In commit db76876db5 (Modules: Use new SOURCES_FROM_* try_compile (1/2), 2022-09-26, v3.25.0-rc1~74^2~1) and commit 41f7b1169a (Modules: Use new SOURCES_FROM_* try_compile (2/2), 2022-09-26, v3.25.0-rc1~74^2) the switch to `SOURCE_FROM_*` required a stronger precondition (the second argument to check_include_files must not have path components) than before (any variable name could be used). Fix that by transforming the variable name to a C identifier before feeding it to try_compile as a filename. The filename is unspecified by the documentation, and the file itself is only temporary, so that should work fine. I have gone through all the occurrences of `SOURCE_FROM_*`, and identified these two that require changes. The rest should work fine as the filenames do not depend on input variable names. Fixes: #24204
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CheckIncludeFiles.cmake5
-rw-r--r--Modules/CheckTypeSize.cmake5
2 files changed, 6 insertions, 4 deletions
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index 8e82859..8fc6921 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -70,10 +70,11 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
message(FATAL_ERROR "Unknown arguments:\n ${ARGN}\n")
endif()
+ string(MAKE_C_IDENTIFIER ${VARIABLE} _variable_escaped)
if(_lang STREQUAL "C")
- set(src ${VARIABLE}.c)
+ set(src ${_variable_escaped}.c)
elseif(_lang STREQUAL "CXX")
- set(src ${VARIABLE}.cpp)
+ set(src ${_variable_escaped}.cpp)
else()
message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n")
endif()
diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake
index b14ab06..e09b7c8 100644
--- a/Modules/CheckTypeSize.cmake
+++ b/Modules/CheckTypeSize.cmake
@@ -103,10 +103,11 @@ function(__check_type_size_impl type var map builtin language)
endif()
# Perform language check
+ string(MAKE_C_IDENTIFIER ${var} _var_escaped)
if(language STREQUAL "C")
- set(src ${var}.c)
+ set(src ${_var_escaped}.c)
elseif(language STREQUAL "CXX")
- set(src ${var}.cpp)
+ set(src ${_var_escaped}.cpp)
else()
message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n")
endif()