summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-16 14:26:30 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-02-16 14:26:49 (GMT)
commit00fcb1dc812dd9578be831156e4c60c458af16c2 (patch)
treec54801d58845cf8f94c7f2f847c087c96caf9c99
parent97132612f63b488e0b8b0913e486083b0e206154 (diff)
parent60a8736378bbef58688c8a3dbfb2d0bce6aa1b6b (diff)
downloadCMake-00fcb1dc812dd9578be831156e4c60c458af16c2.zip
CMake-00fcb1dc812dd9578be831156e4c60c458af16c2.tar.gz
CMake-00fcb1dc812dd9578be831156e4c60c458af16c2.tar.bz2
Merge topic 'cxxmodules-visibility-change-rebuild' into release-3.29
60a8736378 cmNinjaTargetGenerator: scanning depends on the module metadata 52036ce090 Tests/CXXModules: test that objects depend on dependent modules json files 9a45c9fbd5 cmNinjaTargetGenerator: use `emplace_back` for scanning deps Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !9247
-rw-r--r--Source/cmNinjaTargetGenerator.cxx10
-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
7 files changed, 62 insertions, 3 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index d7239f5..fe2cc04 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1222,11 +1222,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
cmNinjaBuild build(this->LanguageDyndepRule(language, config));
build.Outputs.push_back(this->GetDyndepFilePath(language, config));
- build.ImplicitOuts.push_back(
+ build.ImplicitOuts.emplace_back(
cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
this->GetGlobalGenerator()->ConfigDirectory(config), '/',
language, "Modules.json"));
+ build.ImplicitDeps.emplace_back(
+ this->GetTargetDependInfoPath(language, config));
for (auto const& scanFiles : scanningFiles) {
if (!scanFiles.ScanningOutput.empty()) {
build.ExplicitDeps.push_back(scanFiles.ScanningOutput);
@@ -1241,10 +1243,12 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
auto const linked_directories =
this->GetLinkedTargetDirectories(language, config);
for (std::string const& l : linked_directories.Direct) {
- build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json"));
+ build.ImplicitDeps.emplace_back(
+ cmStrCat(l, '/', language, "Modules.json"));
}
for (std::string const& l : linked_directories.Forward) {
- build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json"));
+ build.ImplicitDeps.emplace_back(
+ cmStrCat(l, '/', language, "Modules.json"));
}
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index ff78d5a..f11f82f 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -216,6 +216,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}")