cmTarget: Add GetUtilityItems to get target ordering dependencies

Add a method like GetUtilities but that provides the target names
already looked up and resolved to cmTarget pointers internally.  Update
call site in cmComputeTargetDepends::AddTargetDepend to use the
already-found target instead of looking it up again.
This commit is contained in:
Brad King 2014-06-16 10:58:23 -04:00
parent 4dad5fd20b
commit 097be4139d
3 changed files with 25 additions and 4 deletions

View File

@ -421,12 +421,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
if(dependee->IsImported()) if(dependee->IsImported())
{ {
// Skip imported targets but follow their utility dependencies. // Skip imported targets but follow their utility dependencies.
std::set<std::string> const& utils = dependee->GetUtilities(); std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
for(std::set<std::string>::const_iterator i = utils.begin(); for(std::set<cmLinkItem>::const_iterator i = utils.begin();
i != utils.end(); ++i) i != utils.end(); ++i)
{ {
if(cmTarget const* transitive_dependee = if(cmTarget const* transitive_dependee = i->Target)
dependee->GetMakefile()->FindTargetToUse(*i))
{ {
this->AddTargetDepend(depender_index, transitive_dependee, false); this->AddTargetDepend(depender_index, transitive_dependee, false);
} }

View File

@ -95,11 +95,13 @@ public:
: Backtrace(NULL) : Backtrace(NULL)
{ {
this->PolicyWarnedCMP0022 = false; this->PolicyWarnedCMP0022 = false;
this->UtilityItemsDone = false;
} }
cmTargetInternals(cmTargetInternals const&) cmTargetInternals(cmTargetInternals const&)
: Backtrace(NULL) : Backtrace(NULL)
{ {
this->PolicyWarnedCMP0022 = false; this->PolicyWarnedCMP0022 = false;
this->UtilityItemsDone = false;
} }
~cmTargetInternals(); ~cmTargetInternals();
@ -151,6 +153,9 @@ public:
SourceFilesMapType; SourceFilesMapType;
SourceFilesMapType SourceFilesMap; SourceFilesMapType SourceFilesMap;
std::set<cmLinkItem> UtilityItems;
bool UtilityItemsDone;
struct TargetPropertyEntry { struct TargetPropertyEntry {
TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
const std::string &targetName = std::string()) const std::string &targetName = std::string())
@ -470,6 +475,22 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
return &i->second; return &i->second;
} }
//----------------------------------------------------------------------------
std::set<cmLinkItem> const& cmTarget::GetUtilityItems() const
{
if(!this->Internal->UtilityItemsDone)
{
this->Internal->UtilityItemsDone = true;
for(std::set<std::string>::const_iterator i = this->Utilities.begin();
i != this->Utilities.end(); ++i)
{
this->Internal->UtilityItems.insert(
cmLinkItem(*i, this->Makefile->FindTargetToUse(*i)));
}
}
return this->Internal->UtilityItems;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::FinishConfigure() void cmTarget::FinishConfigure()
{ {

View File

@ -227,6 +227,7 @@ public:
void AddUtility(const std::string& u, cmMakefile *makefile = 0); void AddUtility(const std::string& u, cmMakefile *makefile = 0);
///! Get the utilities used by this target ///! Get the utilities used by this target
std::set<std::string>const& GetUtilities() const { return this->Utilities; } std::set<std::string>const& GetUtilities() const { return this->Utilities; }
std::set<cmLinkItem>const& GetUtilityItems() const;
cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
/** Finalize the target at the end of the Configure step. */ /** Finalize the target at the end of the Configure step. */