From 097be4139df044c86daadb665ec224ee66e6b3bb Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jun 2014 10:58:23 -0400 Subject: 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. --- Source/cmComputeTargetDepends.cxx | 7 +++---- Source/cmTarget.cxx | 21 +++++++++++++++++++++ Source/cmTarget.h | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index a5df060..6196542 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -421,12 +421,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, if(dependee->IsImported()) { // Skip imported targets but follow their utility dependencies. - std::set const& utils = dependee->GetUtilities(); - for(std::set::const_iterator i = utils.begin(); + std::set const& utils = dependee->GetUtilityItems(); + for(std::set::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget const* transitive_dependee = - dependee->GetMakefile()->FindTargetToUse(*i)) + if(cmTarget const* transitive_dependee = i->Target) { this->AddTargetDepend(depender_index, transitive_dependee, false); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e4f26d1..6e4f65f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -95,11 +95,13 @@ public: : Backtrace(NULL) { this->PolicyWarnedCMP0022 = false; + this->UtilityItemsDone = false; } cmTargetInternals(cmTargetInternals const&) : Backtrace(NULL) { this->PolicyWarnedCMP0022 = false; + this->UtilityItemsDone = false; } ~cmTargetInternals(); @@ -151,6 +153,9 @@ public: SourceFilesMapType; SourceFilesMapType SourceFilesMap; + std::set UtilityItems; + bool UtilityItemsDone; + struct TargetPropertyEntry { TargetPropertyEntry(cmsys::auto_ptr cge, const std::string &targetName = std::string()) @@ -471,6 +476,22 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( } //---------------------------------------------------------------------------- +std::set const& cmTarget::GetUtilityItems() const +{ + if(!this->Internal->UtilityItemsDone) + { + this->Internal->UtilityItemsDone = true; + for(std::set::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() { // Erase any cached link information that might have been comptued diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 97c8bf0..c56fa98 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -227,6 +227,7 @@ public: void AddUtility(const std::string& u, cmMakefile *makefile = 0); ///! Get the utilities used by this target std::setconst& GetUtilities() const { return this->Utilities; } + std::setconst& GetUtilityItems() const; cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; /** Finalize the target at the end of the Configure step. */ -- cgit v0.12