Tests/CXXModules: support testing with custom stdlib json locations

This commit is contained in:
Ben Boeckel
2025-09-11 15:44:51 -04:00
parent 6c178a4ae3
commit 2f101b2c8c
2 changed files with 12 additions and 1 deletions

View File

@@ -827,6 +827,7 @@ set_property(TEST RunCMake.DependencyGraph APPEND PROPERTY LABELS "Fortran")
add_RunCMake_test(CXXModules
-DCMake_TEST_MODULE_COMPILATION=${CMake_TEST_MODULE_COMPILATION}
-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}
-DCMake_TEST_CXX_STDLIB_MODULES_JSON=${CMake_TEST_CXX_STDLIB_MODULES_JSON}
)
# ctresalloc links against CMakeLib and CTestLib, which means it can't be built

View File

@@ -1,6 +1,12 @@
include(RunCMake)
run_cmake(Inspect)
set(stdlib_custom_json)
if (CMake_TEST_CXX_STDLIB_MODULES_JSON)
list(APPEND stdlib_custom_json
-DCMAKE_CXX_STDLIB_MODULES_JSON=${CMake_TEST_CXX_STDLIB_MODULES_JSON})
endif ()
run_cmake(Inspect ${stdlib_custom_json})
include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake")
# Test negative cases where C++20 modules do not work.
@@ -149,6 +155,10 @@ function (run_cxx_module_test directory)
else ()
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif ()
if (directory MATCHES "import-std")
list(APPEND RunCMake_TEST_OPTIONS
${stdlib_custom_json})
endif ()
if (RunCMake_CXXModules_INSTALL)
set(prefix "${RunCMake_BINARY_DIR}/examples/${test_name}-install")