Merge topic 'unity-step'

83c1657ff7 Unity build: Generate sources during Compute step

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3884
This commit is contained in:
Brad King 2019-10-04 14:13:13 +00:00 committed by Kitware Robot
commit 395e5f77fc
11 changed files with 28 additions and 10 deletions

View File

@ -1381,6 +1381,11 @@ bool cmGlobalGenerator::Compute()
return false;
}
// Add automatically generated sources (e.g. unity build).
if (!this->AddAutomaticSources()) {
return false;
}
// Add generator specific helper commands
for (cmLocalGenerator* localGen : this->LocalGenerators) {
localGen->AddHelperCommands();
@ -1548,6 +1553,19 @@ bool cmGlobalGenerator::QtAutoGen()
#endif
}
bool cmGlobalGenerator::AddAutomaticSources()
{
for (cmLocalGenerator* lg : this->LocalGenerators) {
for (cmGeneratorTarget* gt : lg->GetGeneratorTargets()) {
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
lg->AddUnityBuild(gt);
}
}
return true;
}
cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer(
cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const
{

View File

@ -503,6 +503,8 @@ protected:
/// @return true on success
bool QtAutoGen();
bool AddAutomaticSources();
std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const;

View File

@ -2827,7 +2827,6 @@ bool cmGlobalXCodeGenerator::CreateGroups(
continue;
}
generator->AddUnityBuild(gtgt, "");
generator->AddPchDependencies(gtgt, "");
auto addSourceToGroup = [this, mf, gtgt,

View File

@ -2452,13 +2452,18 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target,
}
}
void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target,
const std::string& config)
void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
{
if (!target->GetPropertyAsBool("UNITY_BUILD")) {
return;
}
// FIXME: Handle all configurations in multi-config generators.
std::string config;
if (!this->GetGlobalGenerator()->IsMultiConfig()) {
config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
}
const std::string buildType = cmSystemTools::UpperCase(config);
std::string filename_base =

View File

@ -128,7 +128,7 @@ public:
const std::string& rawFlag) const;
void AddPchDependencies(cmGeneratorTarget* target,
const std::string& config);
void AddUnityBuild(cmGeneratorTarget* target, const std::string& config);
void AddUnityBuild(cmGeneratorTarget* target);
void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target,
const std::string& config,
const std::string& lang);

View File

@ -1313,7 +1313,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
const std::string& libName,
cmGeneratorTarget* target)
{
this->AddUnityBuild(target, "");
this->AddPchDependencies(target, "");
std::vector<std::string> configs;

View File

@ -41,7 +41,6 @@ cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
this->LocalGenerator->AddUnityBuild(target, this->ConfigName);
this->LocalGenerator->AddPchDependencies(target, this->ConfigName);
}

View File

@ -43,7 +43,6 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
this->LocalGenerator->AddUnityBuild(target, this->ConfigName);
this->LocalGenerator->AddPchDependencies(target, this->ConfigName);
}

View File

@ -26,7 +26,6 @@ cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator(
cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
this->LocalGenerator->AddUnityBuild(target, this->ConfigName);
this->LocalGenerator->AddPchDependencies(target, this->ConfigName);
}

View File

@ -62,7 +62,6 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
cm::make_unique<cmOSXBundleGenerator>(target, this->GetConfigName());
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
GetLocalGenerator()->AddUnityBuild(target, this->GetConfigName());
GetLocalGenerator()->AddPchDependencies(target, this->GetConfigName());
}

View File

@ -251,7 +251,6 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() ==
this->Makefile->GetCurrentBinaryDirectory());
this->LocalGenerator->AddUnityBuild(target, "");
this->LocalGenerator->AddPchDependencies(target, "");
}