mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
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
This commit is contained in:
@@ -1543,10 +1543,7 @@ bool cmGlobalGenerator::Compute()
|
|||||||
// so create the map from project name to vector of local generators
|
// so create the map from project name to vector of local generators
|
||||||
this->FillProjectMap();
|
this->FillProjectMap();
|
||||||
|
|
||||||
// Add automatically generated sources (e.g. unity build).
|
this->CreateFileGenerateOutputs();
|
||||||
if (!this->AddAutomaticSources()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate through all targets and add verification targets for header sets
|
// Iterate through all targets and add verification targets for header sets
|
||||||
if (!this->AddHeaderSetVerification()) {
|
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
|
// Add unity sources after computing compile features. Unity sources do
|
||||||
// not change the set of languages or features, but we need to know them
|
// 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.
|
// to filter out sources that are scanned for C++ module dependencies.
|
||||||
if (!this->AddUnitySources()) {
|
if (!this->AddAutomaticSources()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1860,16 +1858,21 @@ bool cmGlobalGenerator::AddHeaderSetVerification()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmGlobalGenerator::AddAutomaticSources()
|
void cmGlobalGenerator::CreateFileGenerateOutputs()
|
||||||
{
|
{
|
||||||
for (const auto& lg : this->LocalGenerators) {
|
for (const auto& lg : this->LocalGenerators) {
|
||||||
lg->CreateEvaluationFileOutputs();
|
lg->CreateEvaluationFileOutputs();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmGlobalGenerator::AddAutomaticSources()
|
||||||
|
{
|
||||||
for (const auto& lg : this->LocalGenerators) {
|
for (const auto& lg : this->LocalGenerators) {
|
||||||
for (const auto& gt : lg->GetGeneratorTargets()) {
|
for (const auto& gt : lg->GetGeneratorTargets()) {
|
||||||
if (!gt->CanCompileSources()) {
|
if (!gt->CanCompileSources()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
lg->AddUnityBuild(gt.get());
|
||||||
lg->AddISPCDependencies(gt.get());
|
lg->AddISPCDependencies(gt.get());
|
||||||
// Targets that reuse a PCH are handled below.
|
// Targets that reuse a PCH are handled below.
|
||||||
if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
|
if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
|
||||||
@@ -1901,28 +1904,6 @@ bool cmGlobalGenerator::AddAutomaticSources()
|
|||||||
return true;
|
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(
|
std::unique_ptr<cmLinkLineComputer> cmGlobalGenerator::CreateLinkLineComputer(
|
||||||
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
|
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -676,8 +676,8 @@ protected:
|
|||||||
|
|
||||||
bool AddHeaderSetVerification();
|
bool AddHeaderSetVerification();
|
||||||
|
|
||||||
|
void CreateFileGenerateOutputs();
|
||||||
bool AddAutomaticSources();
|
bool AddAutomaticSources();
|
||||||
bool AddUnitySources();
|
|
||||||
|
|
||||||
std::string SelectMakeProgram(const std::string& makeProgram,
|
std::string SelectMakeProgram(const std::string& makeProgram,
|
||||||
const std::string& makeDefault = "") const;
|
const std::string& makeDefault = "") const;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/PchInterface-check.cmake)
|
||||||
2
Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity.cmake
Normal file
2
Tests/RunCMake/PrecompileHeaders/PchInterfaceUnity.cmake
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
set(CMAKE_UNITY_BUILD 1)
|
||||||
|
include(PchInterface.cmake)
|
||||||
@@ -12,6 +12,7 @@ endfunction()
|
|||||||
run_cmake(DisabledPch)
|
run_cmake(DisabledPch)
|
||||||
run_cmake(PchDebugGenex)
|
run_cmake(PchDebugGenex)
|
||||||
run_test(PchInterface)
|
run_test(PchInterface)
|
||||||
|
run_test(PchInterfaceUnity)
|
||||||
run_cmake(PchPrologueEpilogue)
|
run_cmake(PchPrologueEpilogue)
|
||||||
run_test(SkipPrecompileHeaders)
|
run_test(SkipPrecompileHeaders)
|
||||||
run_test(CXXnotC)
|
run_test(CXXnotC)
|
||||||
|
|||||||
Reference in New Issue
Block a user