summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-12-05 14:25:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-12-05 14:25:50 (GMT)
commitd301276bf5fb1a6336b3a42ab3005332692bf2d0 (patch)
tree76a705ea0dfbb0303654f8e25cf6a3856d1626f4 /Source
parent8c1da0b4bf094ab58591fdf14d5169ad4f49c449 (diff)
parent40dc13b24292354d07b9720d636fa48ab3eee219 (diff)
downloadCMake-d301276bf5fb1a6336b3a42ab3005332692bf2d0.zip
CMake-d301276bf5fb1a6336b3a42ab3005332692bf2d0.tar.gz
CMake-d301276bf5fb1a6336b3a42ab3005332692bf2d0.tar.bz2
Merge topic 'cxxmodules-pch' into release-3.28
40dc13b242 cmNinjaTargetGenerator: PCH files do not need dyndep f61c64cd1c cmLocalGenerator: prevent scanning of PCH source files ea8c37b759 Tests/CXXModules: add a test which scans a PCH-using source Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !9032
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx15
2 files changed, 10 insertions, 8 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index fe8d502..caac535 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2706,6 +2706,9 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
auto* pch_sf = this->Makefile->GetOrCreateSource(
pchSource, false, cmSourceFileLocationKind::Known);
+ // PCH sources should never be scanned as they cannot contain C++
+ // module references.
+ pch_sf->SetProperty("CXX_SCAN_FOR_MODULES", "0");
if (!this->GetGlobalGenerator()->IsXcode()) {
if (!ReuseFrom) {
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 2283923..4025918 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1367,7 +1367,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
!(language == "RC" || (language == "CUDA" && !flag));
int const commandLineLengthLimit =
((lang_supports_response && this->ForceResponseFile())) ? -1 : 0;
- bool const needDyndep =
+ cmValue pchExtension =
+ this->GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION");
+ bool const isPch = cmHasSuffix(objectFileName, pchExtension);
+ bool const needDyndep = !isPch &&
this->GeneratorTarget->NeedDyndepForSource(language, config, source);
cmNinjaBuild objBuild(this->LanguageCompilerRule(
@@ -1435,13 +1438,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
objBuild.Outputs.push_back(objectFileName);
- if (firstForConfig) {
- cmValue pchExtension =
- this->GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION");
- if (!cmHasSuffix(objectFileName, pchExtension)) {
- // Add this object to the list of object files.
- this->Configs[config].Objects.push_back(objectFileName);
- }
+ if (firstForConfig && !isPch) {
+ // Add this object to the list of object files.
+ this->Configs[config].Objects.push_back(objectFileName);
}
objBuild.ExplicitDeps.push_back(sourceFilePath);