summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-02 13:23:31 (GMT)
committerBrad King <brad.king@kitware.com>2024-02-02 14:43:15 (GMT)
commit87bf1c6c33fd774587cd3644ffb8d665111cbb50 (patch)
tree7b9d7f7ee4bc108da3a39068df11ee9f8dbac39c
parent817e309af535dd9f58e1d0248ffb0b7cefc4cb49 (diff)
parentdf08c37a42379cc73dc2dd610a5b87573b24d12e (diff)
downloadCMake-87bf1c6c33fd774587cd3644ffb8d665111cbb50.zip
CMake-87bf1c6c33fd774587cd3644ffb8d665111cbb50.tar.gz
CMake-87bf1c6c33fd774587cd3644ffb8d665111cbb50.tar.bz2
Merge branch 'unity-after-compile-features' into restore-pch-with-unity
Replace commit 76b5383123 (cmGlobalGenerator: add unity sources after computing target compile features, 2024-01-01, v3.28.2~17^2~1) with an alternative change. This merge commit resolves conflicts such that future `git blame` calls will follow the second parent for the relevant lines and pretend the replaced commit never existed. Fixes: #25650
-rw-r--r--Source/cmGlobalGenerator.cxx37
-rw-r--r--Source/cmGlobalGenerator.h2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity-check.cmake1
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity.cmake2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake1
5 files changed, 14 insertions, 29 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5aaa0b8..493d32d 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1543,10 +1543,7 @@ bool cmGlobalGenerator::Compute()
// so create the map from project name to vector of local generators
this->FillProjectMap();
- // Add automatically generated sources (e.g. unity build).
- if (!this->AddAutomaticSources()) {
- return false;
- }
+ this->CreateFileGenerateOutputs();
// Iterate through all targets and add verification targets for header sets
if (!this->AddHeaderSetVerification()) {
@@ -1587,10 +1584,11 @@ bool cmGlobalGenerator::Compute()
}
}
+ // Add automatically generated sources (e.g. unity build).
// Add unity sources after computing compile features. Unity sources do
// not change the set of languages or features, but we need to know them
// to filter out sources that are scanned for C++ module dependencies.
- if (!this->AddUnitySources()) {
+ if (!this->AddAutomaticSources()) {
return false;
}
@@ -1860,16 +1858,21 @@ bool cmGlobalGenerator::AddHeaderSetVerification()
return true;
}
-bool cmGlobalGenerator::AddAutomaticSources()
+void cmGlobalGenerator::CreateFileGenerateOutputs()
{
for (const auto& lg : this->LocalGenerators) {
lg->CreateEvaluationFileOutputs();
}
+}
+
+bool cmGlobalGenerator::AddAutomaticSources()
+{
for (const auto& lg : this->LocalGenerators) {
for (const auto& gt : lg->GetGeneratorTargets()) {
if (!gt->CanCompileSources()) {
continue;
}
+ lg->AddUnityBuild(gt.get());
lg->AddISPCDependencies(gt.get());
// Targets that reuse a PCH are handled below.
if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
@@ -1901,28 +1904,6 @@ bool cmGlobalGenerator::AddAutomaticSources()
return true;
}
-bool cmGlobalGenerator::AddUnitySources()
-{
- for (const auto& lg : this->LocalGenerators) {
- for (const auto& gt : lg->GetGeneratorTargets()) {
- if (!gt->CanCompileSources()) {
- continue;
- }
- lg->AddUnityBuild(gt.get());
- }
- }
- // The above transformation may have changed the classification of sources.
- // Clear the source list and classification cache (KindedSources) of all
- // targets so that it will be recomputed correctly by the generators later
- // now that the above transformations are done for all targets.
- for (const auto& lg : this->LocalGenerators) {
- for (const auto& gt : lg->GetGeneratorTargets()) {
- gt->ClearSourcesCache();
- }
- }
- return true;
-}
-
std::unique_ptr<cmLinkLineComputer> cmGlobalGenerator::CreateLinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 763136e..bc80547 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -676,8 +676,8 @@ protected:
bool AddHeaderSetVerification();
+ void CreateFileGenerateOutputs();
bool AddAutomaticSources();
- bool AddUnitySources();
std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const;
diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity-check.cmake
new file mode 100644
index 0000000..c17aaa0
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity-check.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/PchInterface-check.cmake)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity.cmake
new file mode 100644
index 0000000..59c2523
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_UNITY_BUILD 1)
+include(PchInterface.cmake)
diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
index b163369..c8a5c15 100644
--- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
@@ -12,6 +12,7 @@ endfunction()
run_cmake(DisabledPch)
run_cmake(PchDebugGenex)
run_test(PchInterface)
+run_test(PchInterfaceUnity)
run_cmake(PchPrologueEpilogue)
run_test(SkipPrecompileHeaders)
run_test(CXXnotC)