mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
The TEST_INCLUDE_FILE(S) directory properties were written verbatim into CTestTestfile.cmake, so a $<CONFIG>-parameterized include path could not select a per-configuration script and failed at ctest time. Evaluate generator expressions per include entry in cmLocalGenerator::GenerateTestFiles(): * Entries without a generator expression are emitted unchanged. * On single-config generators a genex entry is evaluated once and emitted as one unconditional include. * On multi-config generators it is evaluated for every configuration; a config-independent result collapses to one unconditional include, otherwise each non-empty per-config result is guarded by a CTEST_CONFIGURATION_TYPE branch, mirroring add_test(). An entry that evaluates to empty adds no include. Promote cmScriptGenerator::CreateConfigTest to a public static helper so the include guards reuse the exact add_test() config-test encoding; the instance overloads now delegate to it. Evaluated results are quoted via cmScriptGenerator::Quote, while plain entries keep their raw serialization. Fixes: #27941
45 lines
1.8 KiB
CMake
45 lines
1.8 KiB
CMake
set(ctf "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake")
|
|
if(NOT EXISTS "${ctf}")
|
|
set(RunCMake_TEST_FAILED "CTestTestfile.cmake not found:\n ${ctf}")
|
|
return()
|
|
endif()
|
|
file(READ "${ctf}" content)
|
|
|
|
# (1) ';' result: split into two separate double-quoted includes (fan-out),
|
|
# not one combined include.
|
|
if(NOT content MATCHES "include\\(\"[^\n]*/a\"\\)")
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"semicolon result first element not emitted as its own include\n")
|
|
endif()
|
|
if(NOT content MATCHES "include\\(\"b[.]cmake\"\\)")
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"semicolon result second element not emitted as its own include\n")
|
|
endif()
|
|
if(content MATCHES "include\\(\"[^\n]*a;b[.]cmake\"\\)")
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"semicolon result was not split into multiple includes\n")
|
|
endif()
|
|
|
|
# (2) space result: double-quoted.
|
|
if(NOT content MATCHES "include\\(\"[^\n]*a b[.]cmake\"\\)")
|
|
string(APPEND RunCMake_TEST_FAILED "space result not double-quoted\n")
|
|
endif()
|
|
|
|
# (3) '$' result: bracket form, and NOT double-quoted.
|
|
if(NOT content MATCHES "include\\(\\[=*\\[[^\n]*x[$]y[.]cmake[^\n]*\\]=*\\]\\)")
|
|
string(APPEND RunCMake_TEST_FAILED "dollar result not emitted in bracket form\n")
|
|
endif()
|
|
if(content MATCHES "include\\(\"[^\n]*x[$]y[.]cmake")
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"dollar result was double-quoted (should be bracketed)\n")
|
|
endif()
|
|
|
|
# (4) plain ${VAR} entry preserved raw and bare (double-quoted, not bracketed).
|
|
if(NOT content MATCHES "include\\(\"[^\n]*lit_[^\n]*MY_VAR[^\n]*[.]cmake\"\\)")
|
|
string(APPEND RunCMake_TEST_FAILED "plain \${VAR} entry not preserved raw\n")
|
|
endif()
|
|
if(content MATCHES "include\\(\\[=*\\[[^\n]*MY_VAR")
|
|
string(APPEND RunCMake_TEST_FAILED
|
|
"plain \${VAR} entry was bracketed (should stay raw double-quoted)\n")
|
|
endif()
|