mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
cmGlobalGenerator: add unity sources after computing target compile features
We need to know which sources will be scanned for C++ module dependencies in order to exclude them from unity builds. The addition of unity sources will not change the set of features.
This commit is contained in:
@@ -1587,6 +1587,13 @@ bool cmGlobalGenerator::Compute()
|
||||
}
|
||||
}
|
||||
|
||||
// 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()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& localGen : this->LocalGenerators) {
|
||||
cmMakefile* mf = localGen->GetMakefile();
|
||||
for (const auto& g : mf->GetInstallGenerators()) {
|
||||
@@ -1863,7 +1870,6 @@ bool cmGlobalGenerator::AddAutomaticSources()
|
||||
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")) {
|
||||
@@ -1895,6 +1901,28 @@ 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
|
||||
{
|
||||
|
||||
@@ -677,6 +677,7 @@ protected:
|
||||
bool AddHeaderSetVerification();
|
||||
|
||||
bool AddAutomaticSources();
|
||||
bool AddUnitySources();
|
||||
|
||||
std::string SelectMakeProgram(const std::string& makeProgram,
|
||||
const std::string& makeDefault = "") const;
|
||||
|
||||
Reference in New Issue
Block a user