mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 10:50:16 -06:00
Check*: Restore support for arbitrary result variable names
In commitdb76876db5(Modules: Use new SOURCES_FROM_* try_compile (1/2), 2022-09-26, v3.25.0-rc1~74^2~1) and commit41f7b1169a(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
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user