Merge topic 'cxxmodules-visibility-change-rebuild'

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
This commit is contained in:
Brad King authored and Kitware Robot committed 2024-02-16 09:26:50 -05:00
commit 4c4951efa8
7 files changed
+62 -3

No files matched your search

+7 -3
View File
@@ -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),
@@ -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.
@@ -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 ()
@@ -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)
@@ -0,0 +1,6 @@
export module importable;
export int from_import()
{
return 0;
}
@@ -0,0 +1,6 @@
import importable;
int main(int argc, char* argv[])
{
return from_import();
}
@@ -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}")