cmLocalGenerator: Store a vector of generator targets.

Not a map from cmTarget to cmGeneratorTarget.
This commit is contained in:
Stephen Kelly 2015-10-18 16:53:00 +02:00
parent e4b7d5afde
commit a8c0fbcc19
15 changed files with 92 additions and 90 deletions

View File

@ -965,13 +965,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
it != this->GlobalGenerator->GetLocalGenerators().end();
++it)
{
cmGeneratorTargetsType targets = (*it)->GetGeneratorTargets();
for (cmGeneratorTargetsType::iterator l = targets.begin();
std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
l != targets.end(); ++l)
{
std::vector<std::string> includeDirs;
std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
(*it)->GetIncludeDirectories(includeDirs, l->second, "C", config);
(*it)->GetIncludeDirectories(includeDirs, *l, "C", config);
this->AppendIncludeDirectories(fout, includeDirs, emmited);
}
}

View File

@ -1584,7 +1584,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
cmTarget* t = &ti->second;
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->GeneratorTargets[t] = gt;
lg->AddGeneratorTarget(t, gt);
lg->AddGeneratorTarget(gt);
}
}

View File

@ -287,8 +287,8 @@ void cmGlobalGhsMultiGenerator::Generate()
{
cmLocalGhsMultiGenerator *lg =
static_cast<cmLocalGhsMultiGenerator *>(this->LocalGenerators[i]);
cmGeneratorTargetsType tgts = lg->GetGeneratorTargets();
this->UpdateBuildFiles(&tgts);
std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
this->UpdateBuildFiles(tgts);
}
}
@ -481,15 +481,15 @@ cmGlobalGhsMultiGenerator::GetFileNameFromPath(std::string const &path)
}
void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
cmGeneratorTargetsType *tgts)
std::vector<cmGeneratorTarget*> tgts)
{
for (cmGeneratorTargetsType::iterator tgtsI = tgts->begin();
tgtsI != tgts->end(); ++tgtsI)
for (std::vector<cmGeneratorTarget*>::iterator tgtsI = tgts.begin();
tgtsI != tgts.end(); ++tgtsI)
{
const cmTarget *tgt(tgtsI->first);
if (IsTgtForBuild(tgt))
const cmGeneratorTarget *tgt = *tgtsI;
if (IsTgtForBuild(tgt->Target))
{
char const *rawFolderName = tgtsI->first->GetProperty("FOLDER");
char const *rawFolderName = tgt->GetProperty("FOLDER");
if (NULL == rawFolderName)
{
rawFolderName = "";
@ -504,13 +504,13 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
GhsMultiGpj::PROJECT);
}
std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(
cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt));
cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt->Target));
std::string foldNameRelBuildFile(*(splitPath.end() - 2) + "/" +
splitPath.back());
*this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile
<< " ";
GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(
tgtsI->second),
tgt),
this->TargetFolderBuildStreams[folderName]);
}
}

View File

@ -110,7 +110,7 @@ private:
std::vector<cmsys::String>::const_iterator end,
GhsMultiGpj::Types projType);
static std::string GetFileNameFromPath(std::string const &path);
void UpdateBuildFiles(cmGeneratorTargetsType *tgts);
void UpdateBuildFiles(std::vector<cmGeneratorTarget*> tgts);
bool IsTgtForBuild(const cmTarget *tgt);
std::vector<cmGeneratedFileStream *> TargetSubProjects;

View File

@ -68,13 +68,14 @@ void cmGlobalKdevelopGenerator::Generate()
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
lg!=lgs.end(); lg++)
{
cmGeneratorTargetsType const& targets = (*lg)->GetGeneratorTargets();
for (cmGeneratorTargetsType::const_iterator ti = targets.begin();
ti != targets.end(); ti++)
std::vector<cmGeneratorTarget*> const& targets =
(*lg)->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::const_iterator ti =
targets.begin(); ti != targets.end(); ti++)
{
if (ti->second->GetType()==cmState::EXECUTABLE)
if ((*ti)->GetType()==cmState::EXECUTABLE)
{
executable = ti->second->GetLocation("");
executable = (*ti)->GetLocation("");
break;
}
}

View File

@ -460,11 +460,11 @@ cmGlobalUnixMakefileGenerator3
// The directory-level rule should depend on the target-level rules
// for all targets in the directory.
std::vector<std::string> depends;
cmGeneratorTargetsType targets = lg->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator l = targets.begin();
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
l != targets.end(); ++l)
{
cmGeneratorTarget* gtarget = l->second;
cmGeneratorTarget* gtarget = *l;
int type = gtarget->GetType();
if((type == cmState::EXECUTABLE) ||
(type == cmState::STATIC_LIBRARY) ||
@ -623,11 +623,11 @@ cmGlobalUnixMakefileGenerator3
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->LocalGenerators[i]);
// for each target Generate the rule files for each target.
cmGeneratorTargetsType targets = lg->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
cmGeneratorTarget* gtarget = t->second;
cmGeneratorTarget* gtarget = *t;
// Don't emit the same rule twice (e.g. two targets with the same
// simple name)
int type = gtarget->GetType();
@ -720,11 +720,11 @@ cmGlobalUnixMakefileGenerator3
depends.push_back("cmake_check_build_system");
// for each target Generate the rule files for each target.
cmGeneratorTargetsType targets = lg->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
cmGeneratorTarget* gtarget = t->second;
cmGeneratorTarget* gtarget = *t;
int type = gtarget->GetType();
std::string name = gtarget->GetName();
if (!name.empty()

View File

@ -256,7 +256,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
noCommandLines);
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
lg->AddGeneratorTarget(tgt, gt);
lg->AddGeneratorTarget(gt);
this->AddGeneratorTarget(tgt, gt);
// Organize in the "predefined targets" folder:

View File

@ -87,7 +87,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
"Build all projects");
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
gen[0]->AddGeneratorTarget(allBuild, gt);
gen[0]->AddGeneratorTarget(gt);
this->AddGeneratorTarget(allBuild, gt);
#if 0
@ -108,19 +108,20 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
i != gen.end(); ++i)
{
cmGeneratorTargetsType targets =
std::vector<cmGeneratorTarget*> targets =
(*i)->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
if (t->second->GetType() == cmState::GLOBAL_TARGET
|| t->first->IsImported())
cmGeneratorTarget* tgt = *t;
if (tgt->GetType() == cmState::GLOBAL_TARGET
|| tgt->IsImported())
{
continue;
}
if(!this->IsExcluded(gen[0], t->second))
if(!this->IsExcluded(gen[0], tgt))
{
allBuild->AddUtility(t->second->GetName());
allBuild->AddUtility(tgt->GetName());
}
}
}

View File

@ -459,7 +459,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
"echo", "Build all projects");
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
root->AddGeneratorTarget(allbuild, allBuildGt);
root->AddGeneratorTarget(allBuildGt);
root->GetGlobalGenerator()->AddGeneratorTarget(allbuild, allBuildGt);
// Refer to the main build configuration file for easy editing.
@ -495,7 +495,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
"make", "-f", file.c_str());
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
root->AddGeneratorTarget(check, checkGt);
root->AddGeneratorTarget(checkGt);
root->GetGlobalGenerator()->AddGeneratorTarget(check, checkGt);
}

View File

@ -132,15 +132,15 @@ void cmLocalGenerator::TraceDependencies()
this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
}
// Generate the rule files for each target.
cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
if (t->second->GetType() == cmState::INTERFACE_LIBRARY)
if ((*t)->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
t->second->TraceDependencies();
(*t)->TraceDependencies();
}
}
@ -448,9 +448,9 @@ void cmLocalGenerator::GenerateInstallRules()
}
void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
{
this->GeneratorTargets[t] = gt;
this->GeneratorTargets.push_back(gt);
}
//----------------------------------------------------------------------------
@ -465,12 +465,12 @@ void cmLocalGenerator::ComputeTargetManifest()
}
// Add our targets to the manifest for each configuration.
cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
cmGeneratorTarget& target = *t->second;
if (target.GetType() == cmState::INTERFACE_LIBRARY)
cmGeneratorTarget* target = *t;
if (target->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
@ -478,7 +478,7 @@ void cmLocalGenerator::ComputeTargetManifest()
ci != configNames.end(); ++ci)
{
const char* config = ci->c_str();
target.ComputeTargetManifest(config);
target->ComputeTargetManifest(config);
}
}
}

View File

@ -113,12 +113,12 @@ public:
bool forResponseFile = false,
const std::string& config = "");
const cmGeneratorTargetsType &GetGeneratorTargets() const
const std::vector<cmGeneratorTarget*> &GetGeneratorTargets() const
{
return this->GeneratorTargets;
}
void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt);
void AddGeneratorTarget(cmGeneratorTarget* gt);
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
@ -367,7 +367,7 @@ protected:
std::set<std::string> ObjectMaxPathViolations;
std::set<cmGeneratorTarget const*> WarnCMP0063;
cmGeneratorTargetsType GeneratorTargets;
std::vector<cmGeneratorTarget*> GeneratorTargets;
bool EmitUniversalBinaryFlags;

View File

@ -26,16 +26,16 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {}
void cmLocalGhsMultiGenerator::Generate()
{
cmGeneratorTargetsType tgts = this->GetGeneratorTargets();
std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end();
++l)
for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
l != tgts.end(); ++l)
{
if (l->second->GetType() == cmState::INTERFACE_LIBRARY)
if ((*l)->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
cmGhsMultiTargetGenerator tg(l->second);
cmGhsMultiTargetGenerator tg(*l);
tg.Generate();
}
}

View File

@ -73,23 +73,23 @@ void cmLocalNinjaGenerator::Generate()
}
}
cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
if (t->second->GetType() == cmState::INTERFACE_LIBRARY)
if ((*t)->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(t->second);
cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(*t);
if(tg)
{
tg->Generate();
// Add the target to "all" if required.
if (!this->GetGlobalNinjaGenerator()->IsExcluded(
this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0],
t->second))
this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target);
*t))
this->GetGlobalNinjaGenerator()->AddDependencyToAll((*t)->Target);
delete tg;
}
}

View File

@ -113,18 +113,18 @@ void cmLocalUnixMakefileGenerator3::Generate()
this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES");
// Generate the rule files for each target.
cmGeneratorTargetsType targets = this->GetGeneratorTargets();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
for(cmGeneratorTargetsType::iterator t = targets.begin();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
if (t->second->GetType() == cmState::INTERFACE_LIBRARY)
if ((*t)->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
}
cmsys::auto_ptr<cmMakefileTargetGenerator> tg(
cmMakefileTargetGenerator::New(t->second));
cmMakefileTargetGenerator::New(*t));
if (tg.get())
{
tg->WriteRuleFiles();
@ -174,11 +174,11 @@ void cmLocalUnixMakefileGenerator3::
GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
{
std::set<std::string> emitted;
cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator ti = targets.begin();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
for(std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
ti != targets.end(); ++ti)
{
cmGeneratorTarget* gt = ti->second;
cmGeneratorTarget* gt = *ti;
if (gt->GetType() == cmState::INTERFACE_LIBRARY)
{
continue;
@ -417,22 +417,22 @@ void cmLocalUnixMakefileGenerator3
// for each target we just provide a rule to cd up to the top and do a make
// on the target
cmGeneratorTargetsType targets = this->GetGeneratorTargets();
std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
std::string localName;
for(cmGeneratorTargetsType::iterator t = targets.begin();
for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
t != targets.end(); ++t)
{
if((t->second->GetType() == cmState::EXECUTABLE) ||
(t->second->GetType() == cmState::STATIC_LIBRARY) ||
(t->second->GetType() == cmState::SHARED_LIBRARY) ||
(t->second->GetType() == cmState::MODULE_LIBRARY) ||
(t->second->GetType() == cmState::OBJECT_LIBRARY) ||
(t->second->GetType() == cmState::UTILITY))
if(((*t)->GetType() == cmState::EXECUTABLE) ||
((*t)->GetType() == cmState::STATIC_LIBRARY) ||
((*t)->GetType() == cmState::SHARED_LIBRARY) ||
((*t)->GetType() == cmState::MODULE_LIBRARY) ||
((*t)->GetType() == cmState::OBJECT_LIBRARY) ||
((*t)->GetType() == cmState::UTILITY))
{
emitted.insert(t->second->GetName());
emitted.insert((*t)->GetName());
// for subdirs add a rule to build this specific target by name.
localName = this->GetRelativeTargetDirectory(t->second);
localName = this->GetRelativeTargetDirectory(*t);
localName += "/rule";
commands.clear();
depends.clear();
@ -449,23 +449,23 @@ void cmLocalUnixMakefileGenerator3
localName, depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
if(localName != t->second->GetName())
if(localName != (*t)->GetName())
{
commands.clear();
depends.push_back(localName);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
t->second->GetName(), depends, commands, true);
(*t)->GetName(), depends, commands, true);
}
// Add a fast rule to build the target
std::string makefileName =
this->GetRelativeTargetDirectory(t->second);
this->GetRelativeTargetDirectory(*t);
makefileName += "/build.make";
// make sure the makefile name is suitable for a makefile
std::string makeTargetName =
this->GetRelativeTargetDirectory(t->second);
this->GetRelativeTargetDirectory(*t);
makeTargetName += "/build";
localName = t->second->GetName();
localName = (*t)->GetName();
localName += "/fast";
depends.clear();
commands.clear();
@ -479,11 +479,11 @@ void cmLocalUnixMakefileGenerator3
// Add a local name for the rule to relink the target before
// installation.
if(t->second->NeedRelinkBeforeInstall(this->ConfigName))
if((*t)->NeedRelinkBeforeInstall(this->ConfigName))
{
makeTargetName = this->GetRelativeTargetDirectory(t->second);
makeTargetName = this->GetRelativeTargetDirectory(*t);
makeTargetName += "/preinstall";
localName = t->second->GetName();
localName = (*t)->GetName();
localName += "/preinstall";
depends.clear();
commands.clear();

View File

@ -895,7 +895,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
commandLines, false, autogenComment.c_str());
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
lg->AddGeneratorTarget(autogenTarget, gt);
lg->AddGeneratorTarget(gt);
lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt);
// Set target folder