summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-02-14 22:19:42 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-02-15 03:36:37 (GMT)
commit52036ce090cf6f94a9389c2614b88cc8966f6e32 (patch)
tree92decf6db0cea9cbb99f747284da6238708e085e
parent9a45c9fbd55798f9636778504562cd03e293da2e (diff)
downloadCMake-52036ce090cf6f94a9389c2614b88cc8966f6e32.zip
CMake-52036ce090cf6f94a9389c2614b88cc8966f6e32.tar.gz
CMake-52036ce090cf6f94a9389c2614b88cc8966f6e32.tar.bz2
Tests/CXXModules: test that objects depend on dependent modules json files
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake12
-rw-r--r--Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/CMakeLists.txt23
-rw-r--r--Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/main.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/pre-rebuild.cmake7
6 files changed, 55 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index b996df0..7958166 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -215,6 +215,7 @@ if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(req-private-other-target)
unset(RunCMake_CXXModules_NO_TEST)
run_cxx_module_test_rebuild(depchain-modmap)
+ run_cxx_module_test_rebuild(depchain-modules-json-file)
endif ()
# Tests which use named modules in shared libraries.
diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake
new file mode 100644
index 0000000..452f446
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file-rebuild-check.cmake
@@ -0,0 +1,12 @@
+if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(dep_modules_json_path "CMakeFiles/depchain_modules_json_file.dir/Debug/CXXModules.json")
+ set(modules_json_path "CMakeFiles/depchain_with_modules_json_file.dir/Debug/CXXModules.json")
+else ()
+ set(dep_modules_json_path "CMakeFiles/depchain_modules_json_file.dir/CXXModules.json")
+ set(modules_json_path "CMakeFiles/depchain_with_modules_json_file.dir/CXXModules.json")
+endif ()
+
+if ("${RunCMake_TEST_BINARY_DIR}/${modules_json_path}" IS_NEWER_THAN "${RunCMake_TEST_BINARY_DIR}/${dep_modules_json_path}")
+ list(APPEND RunCMake_TEST_FAILED
+ "Object '${dep_modules_json_path}' should have recompiled if '${modules_json_path}' changed.")
+endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/CMakeLists.txt
new file mode 100644
index 0000000..9828ee6
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_depchain_modules_json_file CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(depchain_with_modules_json_file)
+target_sources(depchain_with_modules_json_file
+ PUBLIC
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx)
+target_compile_features(depchain_with_modules_json_file PUBLIC cxx_std_20)
+
+add_executable(depchain_modules_json_file)
+target_sources(depchain_modules_json_file
+ PRIVATE
+ main.cxx)
+target_link_libraries(depchain_modules_json_file
+ PRIVATE
+ depchain_with_modules_json_file)
+add_test(NAME depchain_modules_json_file COMMAND depchain_modules_json_file)
diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/importable.cxx b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/importable.cxx
new file mode 100644
index 0000000..607680a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/main.cxx b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/main.cxx
new file mode 100644
index 0000000..feb38d2
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/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-modules-json-file/pre-rebuild.cmake b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/pre-rebuild.cmake
new file mode 100644
index 0000000..9c3f2ff
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/depchain-modules-json-file/pre-rebuild.cmake
@@ -0,0 +1,7 @@
+if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(modules_json_path "CMakeFiles/depchain_with_modules_json_file.dir/Debug/CXXModules.json")
+else ()
+ set(modules_json_path "CMakeFiles/depchain_with_modules_json_file.dir/CXXModules.json")
+endif ()
+
+file(TOUCH_NOCREATE "${RunCMake_TEST_BINARY_DIR}/${modules_json_path}")