cmGlobalGenerator: Add FindGeneratorTarget API

This commit is contained in:
Stephen Kelly 2015-10-25 13:06:59 +01:00
parent 278ba2db47
commit 8caf1f361b
2 changed files with 54 additions and 0 deletions

View File

@ -2196,6 +2196,25 @@ cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
return 0; return 0;
} }
cmGeneratorTarget*
cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->GetName() == name)
{
return *it;
}
}
}
return 0;
}
cmTarget* cmTarget*
cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
{ {
@ -2215,6 +2234,25 @@ cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
return 0; return 0;
} }
cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
std::string const& name) const
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
{
std::vector<cmGeneratorTarget*> tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
it != tgts.end(); ++it)
{
if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
{
return *it;
}
}
}
return 0;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmTarget*
cmGlobalGenerator::FindTarget(const std::string& name, cmGlobalGenerator::FindTarget(const std::string& name,
@ -2236,6 +2274,16 @@ cmGlobalGenerator::FindTarget(const std::string& name,
return this->FindImportedTargetImpl(name); return this->FindImportedTargetImpl(name);
} }
cmGeneratorTarget*
cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
{
if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
{
return tgt;
}
return this->FindImportedGeneratorTargetImpl(name);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const

View File

@ -254,6 +254,8 @@ public:
cmTarget* FindTarget(const std::string& name, cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const; bool excludeAliases = false) const;
cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
void AddAlias(const std::string& name, const std::string& tgtName); void AddAlias(const std::string& name, const std::string& tgtName);
bool IsAlias(const std::string& name) const; bool IsAlias(const std::string& name) const;
@ -432,6 +434,10 @@ protected:
cmTarget* FindTargetImpl(std::string const& name) const; cmTarget* FindTargetImpl(std::string const& name) const;
cmTarget* FindImportedTargetImpl(std::string const& name) const; cmTarget* FindImportedTargetImpl(std::string const& name) const;
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
cmGeneratorTarget*
FindImportedGeneratorTargetImpl(std::string const& name) const;
const char* GetPredefinedTargetsFolder(); const char* GetPredefinedTargetsFolder();
virtual bool UseFolderProperty(); virtual bool UseFolderProperty();