cmLocalGenerator: Port Find method away from GetGeneratorTarget
Mirror the cmMakefile::FindTarget method.
This commit is contained in:
parent
02533038da
commit
c389f8bb07
|
@ -1583,10 +1583,12 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
|
void cmGlobalGenerator::CreateGeneratorTargets(
|
||||||
cmLocalGenerator *lg)
|
TargetTypes targetTypes,
|
||||||
|
cmMakefile *mf,
|
||||||
|
cmLocalGenerator *lg,
|
||||||
|
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap)
|
||||||
{
|
{
|
||||||
cmMakefile* mf = lg->GetMakefile();
|
|
||||||
if (targetTypes == AllTargets)
|
if (targetTypes == AllTargets)
|
||||||
{
|
{
|
||||||
cmTargets& targets = mf->GetTargets();
|
cmTargets& targets = mf->GetTargets();
|
||||||
|
@ -1600,23 +1602,38 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<cmTarget*> itgts = mf->GetImportedTargets();
|
||||||
|
|
||||||
for(std::vector<cmTarget*>::const_iterator
|
for(std::vector<cmTarget*>::const_iterator
|
||||||
j = mf->GetOwnedImportedTargets().begin();
|
j = itgts.begin(); j != itgts.end(); ++j)
|
||||||
j != mf->GetOwnedImportedTargets().end(); ++j)
|
|
||||||
{
|
{
|
||||||
cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
|
lg->AddImportedGeneratorTarget(importedMap.find(*j)->second);
|
||||||
this->GeneratorTargets[*j] = gt;
|
|
||||||
lg->AddImportedGeneratorTarget(gt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
|
void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
|
||||||
{
|
{
|
||||||
|
std::map<cmTarget*, cmGeneratorTarget*> importedMap;
|
||||||
|
for(unsigned int i=0; i < this->Makefiles.size(); ++i)
|
||||||
|
{
|
||||||
|
cmMakefile* mf = this->Makefiles[i];
|
||||||
|
for(std::vector<cmTarget*>::const_iterator
|
||||||
|
j = mf->GetOwnedImportedTargets().begin();
|
||||||
|
j != mf->GetOwnedImportedTargets().end(); ++j)
|
||||||
|
{
|
||||||
|
cmGeneratorTarget* gt =
|
||||||
|
new cmGeneratorTarget(*j, this->LocalGenerators[i]);
|
||||||
|
this->GeneratorTargets[*j] = gt;
|
||||||
|
importedMap[*j] = gt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Construct per-target generator information.
|
// Construct per-target generator information.
|
||||||
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
|
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
|
||||||
{
|
{
|
||||||
this->CreateGeneratorTargets(targetTypes, this->LocalGenerators[i]);
|
this->CreateGeneratorTargets(targetTypes, this->Makefiles[i],
|
||||||
|
this->LocalGenerators[i], importedMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2240,11 +2257,11 @@ cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
|
||||||
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
{
|
{
|
||||||
std::vector<cmGeneratorTarget*> tgts =
|
std::vector<cmGeneratorTarget*> tgts =
|
||||||
this->LocalGenerators[i]->GetGeneratorTargets();
|
this->LocalGenerators[i]->GetImportedGeneratorTargets();
|
||||||
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
|
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
|
||||||
it != tgts.end(); ++it)
|
it != tgts.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
|
if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name)
|
||||||
{
|
{
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,7 +485,9 @@ private:
|
||||||
// Per-target generator information.
|
// Per-target generator information.
|
||||||
cmGeneratorTargetsType GeneratorTargets;
|
cmGeneratorTargetsType GeneratorTargets;
|
||||||
friend class cmake;
|
friend class cmake;
|
||||||
void CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator* lg);
|
void CreateGeneratorTargets(TargetTypes targetTypes, cmMakefile* mf,
|
||||||
|
cmLocalGenerator* lg,
|
||||||
|
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
|
||||||
void CreateGeneratorTargets(TargetTypes targetTypes);
|
void CreateGeneratorTargets(TargetTypes targetTypes);
|
||||||
|
|
||||||
void ClearGeneratorMembers();
|
void ClearGeneratorMembers();
|
||||||
|
|
|
@ -1821,11 +1821,21 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
||||||
cmGeneratorTarget*
|
cmGeneratorTarget*
|
||||||
cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
|
cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
|
||||||
{
|
{
|
||||||
if (cmTarget *t = this->Makefile->FindTargetToUse(name))
|
std::vector<cmGeneratorTarget*>::const_iterator
|
||||||
|
imported = std::find_if(this->ImportedGeneratorTargets.begin(),
|
||||||
|
this->ImportedGeneratorTargets.end(),
|
||||||
|
NamedGeneratorTargetFinder(name));
|
||||||
|
if(imported != this->ImportedGeneratorTargets.end())
|
||||||
{
|
{
|
||||||
return this->GetGlobalGenerator()->GetGeneratorTarget(t);
|
return *imported;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
if(cmGeneratorTarget* t = this->FindGeneratorTarget(name))
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->GetGlobalGenerator()->FindGeneratorTarget(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -120,6 +120,11 @@ public:
|
||||||
return this->GeneratorTargets;
|
return this->GeneratorTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<cmGeneratorTarget*> &GetImportedGeneratorTargets() const
|
||||||
|
{
|
||||||
|
return this->ImportedGeneratorTargets;
|
||||||
|
}
|
||||||
|
|
||||||
void AddGeneratorTarget(cmGeneratorTarget* gt);
|
void AddGeneratorTarget(cmGeneratorTarget* gt);
|
||||||
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
|
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue