diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-02-14 19:20:57 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2024-02-15 01:36:47 (GMT) |
commit | 940628d48deb53a3a79d07e3e6e22cf405021543 (patch) | |
tree | 0afe0761ad4e7e065c27f23e44c9a0a5443d61d9 | |
parent | 681ee920307a6c1ddafa1d6d4b0329050a7ac689 (diff) | |
download | CMake-940628d48deb53a3a79d07e3e6e22cf405021543.zip CMake-940628d48deb53a3a79d07e3e6e22cf405021543.tar.gz CMake-940628d48deb53a3a79d07e3e6e22cf405021543.tar.bz2 |
Tests/CXXModules: test that objects depend on their modmap files
6 files changed, 49 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 8e5abdd..b996df0 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -214,6 +214,7 @@ if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION) set(RunCMake_CXXModules_NO_TEST 1) run_cxx_module_test(req-private-other-target) unset(RunCMake_CXXModules_NO_TEST) + run_cxx_module_test_rebuild(depchain-modmap) endif () # Tests which use named modules in shared libraries. diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modmap-rebuild-check.cmake b/Tests/RunCMake/CXXModules/examples/depchain-modmap-rebuild-check.cmake new file mode 100644 index 0000000..1596632 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-modmap-rebuild-check.cmake @@ -0,0 +1,11 @@ +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(object_path "CMakeFiles/depchain_modmap.dir/Debug/main.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") +else () + set(object_path "CMakeFiles/depchain_modmap.dir/main.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") +endif () +set(modmap_path "${object_path}.modmap") + +if ("${RunCMake_TEST_BINARY_DIR}/${modmap_path}" IS_NEWER_THAN "${RunCMake_TEST_BINARY_DIR}/${object_path}") + list(APPEND RunCMake_TEST_FAILED + "Object '${object_path}' should have recompiled if '${modmap_path}' changed.") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modmap/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/depchain-modmap/CMakeLists.txt new file mode 100644 index 0000000..11712e9 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-modmap/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.28) +project(cxx_modules_depchain_modmap CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_executable(depchain_modmap) +target_sources(depchain_modmap + PRIVATE + main.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(depchain_modmap PUBLIC cxx_std_20) + +add_test(NAME depchain_modmap COMMAND depchain_modmap) diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modmap/importable.cxx b/Tests/RunCMake/CXXModules/examples/depchain-modmap/importable.cxx new file mode 100644 index 0000000..607680a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-modmap/importable.cxx @@ -0,0 +1,6 @@ +export module importable; + +export int from_import() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modmap/main.cxx b/Tests/RunCMake/CXXModules/examples/depchain-modmap/main.cxx new file mode 100644 index 0000000..feb38d2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-modmap/main.cxx @@ -0,0 +1,6 @@ +import importable; + +int main(int argc, char* argv[]) +{ + return from_import(); +} diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modmap/pre-rebuild.cmake b/Tests/RunCMake/CXXModules/examples/depchain-modmap/pre-rebuild.cmake new file mode 100644 index 0000000..f434cbe --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/depchain-modmap/pre-rebuild.cmake @@ -0,0 +1,7 @@ +if (RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(modmap_path "CMakeFiles/depchain_modmap.dir/Debug/main.cxx${CMAKE_CXX_OUTPUT_EXTENSION}.modmap") +else () + set(modmap_path "CMakeFiles/depchain_modmap.dir/main.cxx${CMAKE_CXX_OUTPUT_EXTENSION}.modmap") +endif () + +file(TOUCH_NOCREATE "${RunCMake_TEST_BINARY_DIR}/${modmap_path}") |