cmGlobalGenerator: Use cmMakefile::CreateNewTarget to add global targets

`cmMakefile::CreateNewTarget` updates also `cmMakefile::OrderedTargets`.
This commit is contained in:
NAKAMURA Takumi
2021-07-08 23:10:06 +09:00
committed by Brad King
parent 854dcb0d01
commit 8a812dde61
2 changed files with 13 additions and 10 deletions

View File

@@ -1263,10 +1263,8 @@ void cmGlobalGenerator::Configure()
this->CreateDefaultGlobalTargets(globalTargets);
for (const auto& mf : this->Makefiles) {
auto& targets = mf->GetTargets();
for (GlobalTargetInfo const& globalTarget : globalTargets) {
targets.emplace(globalTarget.Name,
this->CreateGlobalTarget(globalTarget, mf.get()));
this->CreateGlobalTarget(globalTarget, mf.get());
}
}
}
@@ -2824,12 +2822,19 @@ bool cmGlobalGenerator::UseFolderProperty() const
return false;
}
cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
cmMakefile* mf)
void cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
cmMakefile* mf)
{
// Package
cmTarget target(gti.Name, cmStateEnums::GLOBAL_TARGET,
cmTarget::VisibilityNormal, mf, gti.PerConfig);
auto tb =
mf->CreateNewTarget(gti.Name, cmStateEnums::GLOBAL_TARGET, gti.PerConfig);
// Do nothing if gti.Name is already used
if (!tb.second) {
return;
}
cmTarget& target = tb.first;
target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
std::vector<std::string> no_outputs;
@@ -2853,8 +2858,6 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
if (this->UseFolderProperty()) {
target.SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
}
return target;
}
std::string cmGlobalGenerator::GenerateRuleFile(

View File

@@ -596,7 +596,7 @@ protected:
void AddGlobalTarget_RebuildCache(
std::vector<GlobalTargetInfo>& targets) const;
void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets);
cmTarget CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf);
void CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf);
std::string FindMakeProgramFile;
std::string ConfiguredFilesPath;