From 190cabe7c1641482529bba34d46a38e4e33a2384 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 16:02:46 -0400 Subject: [PATCH 1/8] cmTarget: Drop 'head' argument from ComputeLinkImplementationLanguages No call sites need it to be anything but 'this'. --- Source/cmTarget.cxx | 7 +++---- Source/cmTarget.h | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a740bc35b..d74c66b1e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6405,7 +6405,7 @@ cmTarget::GetLinkImplementation(const std::string& config) const if(!impl.LanguagesDone) { impl.LanguagesDone = true; - this->ComputeLinkImplementationLanguages(config, impl, this); + this->ComputeLinkImplementationLanguages(config, impl); } return &impl; } @@ -6546,13 +6546,12 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, //---------------------------------------------------------------------------- void cmTarget::ComputeLinkImplementationLanguages(const std::string& config, - LinkImplementation& impl, - cmTarget const* head) const + LinkImplementation& impl) const { // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->GetLanguages(languages, config, head); + this->GetLanguages(languages, config, this); // Copy the set of langauges to the link implementation. for(std::set::iterator li = languages.begin(); li != languages.end(); ++li) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dc67f1e78..908e4ba28 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -787,8 +787,7 @@ private: LinkImplementation& impl, cmTarget const* head) const; void ComputeLinkImplementationLanguages(const std::string& config, - LinkImplementation& impl, - cmTarget const* head) const; + LinkImplementation& impl) const; void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, From 4c763dd1f1c922606660e275372cc6313ac42535 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 16:06:36 -0400 Subject: [PATCH 2/8] cmTarget: Drop 'head' argument from GetLanguages No call sites need it to be anything but 'this'. --- Source/cmTarget.cxx | 9 ++++----- Source/cmTarget.h | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d74c66b1e..e1ce4ddaa 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5419,11 +5419,10 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const //---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages, - const std::string& config, - cmTarget const* head) const + const std::string& config) const { std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config, head); + this->GetSourceFiles(sourceFiles, config, this); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { @@ -5459,7 +5458,7 @@ void cmTarget::GetLanguages(std::set& languages, for(std::vector::const_iterator i = objectLibraries.begin(); i != objectLibraries.end(); ++i) { - (*i)->GetLanguages(languages, config, head); + (*i)->GetLanguages(languages, config); } } @@ -6551,7 +6550,7 @@ cmTarget::ComputeLinkImplementationLanguages(const std::string& config, // This target needs runtime libraries for its source languages. std::set languages; // Get languages used in our source files. - this->GetLanguages(languages, config, this); + this->GetLanguages(languages, config); // Copy the set of langauges to the link implementation. for(std::set::iterator li = languages.begin(); li != languages.end(); ++li) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 908e4ba28..d5fb5e819 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -491,8 +491,7 @@ public: // information to forward these property changes to the targets // until we have per-target object file properties. void GetLanguages(std::set& languages, - std::string const& config, - cmTarget const* head = 0) const; + std::string const& config) const; /** Return whether this target is an executable with symbol exports enabled. */ From 4b8130b8de223674d567bdff5e156b1bdc1d5c27 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 16:07:31 -0400 Subject: [PATCH 3/8] cmTarget: Drop 'head' argument from GetSourceFiles No call sites need it to be anything but 'this'. --- Source/cmTarget.cxx | 20 +++++++++----------- Source/cmTarget.h | 6 ++---- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1ce4ddaa..5865c61b8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -158,8 +158,8 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - typedef std::map > - SourceFilesMapType; + typedef std::map > + SourceFilesMapType; SourceFilesMapType SourceFilesMap; std::set UtilityItems; @@ -707,8 +707,7 @@ static bool processSources(cmTarget const* tgt, //---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, - const std::string& config, - cmTarget const* head) const + const std::string& config) const { assert(this->GetType() != INTERFACE_LIBRARY); @@ -772,7 +771,7 @@ void cmTarget::GetSourceFiles(std::vector &files, files, uniqueSrcs, &dagChecker, - head, + this, config, debugSources); @@ -789,7 +788,7 @@ void cmTarget::GetSourceFiles(std::vector &files, files, uniqueSrcs, &dagChecker, - head, + this, config, debugSources); @@ -868,12 +867,11 @@ cmTarget::GetConfigCommonSourceFiles(std::vector& files) const //---------------------------------------------------------------------------- void cmTarget::GetSourceFiles(std::vector &files, - const std::string& config, - cmTarget const* head) const + const std::string& config) const { // Lookup any existing link implementation for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config)); + std::string key = cmSystemTools::UpperCase(config); if(!this->LinkImplementationLanguageIsContextDependent) { @@ -890,7 +888,7 @@ void cmTarget::GetSourceFiles(std::vector &files, else { std::vector srcs; - this->GetSourceFiles(srcs, config, head); + this->GetSourceFiles(srcs, config); std::set emitted; @@ -5422,7 +5420,7 @@ void cmTarget::GetLanguages(std::set& languages, const std::string& config) const { std::vector sourceFiles; - this->GetSourceFiles(sourceFiles, config, this); + this->GetSourceFiles(sourceFiles, config); for(std::vector::const_iterator i = sourceFiles.begin(); i != sourceFiles.end(); ++i) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5fb5e819..39a0667a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -161,8 +161,7 @@ public: * Get the list of the source files used by this target */ void GetSourceFiles(std::vector &files, - const std::string& config, - cmTarget const* head = 0) const; + const std::string& config) const; bool GetConfigCommonSourceFiles(std::vector& files) const; /** @@ -711,8 +710,7 @@ private: bool contentOnly) const; void GetSourceFiles(std::vector &files, - const std::string& config, - cmTarget const* head = 0) const; + const std::string& config) const; private: std::string Name; std::vector PreBuildCommands; From 4db3990e9f3c11add85cba339b7a976f6f0fd3c5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 16:12:05 -0400 Subject: [PATCH 4/8] cmTarget: Drop 'head' argument from processSources No call sites need it to be anything but 'this'. --- Source/cmTarget.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5865c61b8..d1938d1c2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -624,7 +624,6 @@ static bool processSources(cmTarget const* tgt, std::vector &srcs, std::set &uniqueSrcs, cmGeneratorExpressionDAGChecker *dagChecker, - cmTarget const* head, std::string const& config, bool debugSources) { cmMakefile *mf = tgt->GetMakefile(); @@ -641,7 +640,7 @@ static bool processSources(cmTarget const* tgt, cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, config, false, - head ? head : tgt, + tgt, tgt, dagChecker), entrySources); @@ -771,7 +770,6 @@ void cmTarget::GetSourceFiles(std::vector &files, files, uniqueSrcs, &dagChecker, - this, config, debugSources); @@ -788,7 +786,6 @@ void cmTarget::GetSourceFiles(std::vector &files, files, uniqueSrcs, &dagChecker, - this, config, debugSources); From c69e8a5580bd034dcaa1d7d53976200600b26b82 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 16:59:16 -0400 Subject: [PATCH 5/8] cmTarget: Refactor internal LinkInterface map Create the map entry up front and store in it boolean values indicating which pieces of the LinkInterface structure have been populated. This approach leads to shorter code that is easier to follow too. --- Source/cmTarget.cxx | 46 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d1938d1c2..3361a8142 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -112,9 +112,11 @@ public: struct OptionalLinkInterface: public cmTarget::LinkInterface { OptionalLinkInterface(): - Exists(false), Complete(false), ExplicitLibraries(0) {} + LibrariesDone(false), AllDone(false), + Exists(false), ExplicitLibraries(0) {} + bool LibrariesDone; + bool AllDone; bool Exists; - bool Complete; const char* ExplicitLibraries; }; void ComputeLinkInterface(cmTarget const* thisTarget, @@ -5895,32 +5897,26 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( // Lookup any existing link interface for this configuration. TargetConfigPair key(head, cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkInterfaceMapType::iterator - i = this->Internal->LinkInterfaceMap.find(key); - if(i == this->Internal->LinkInterfaceMap.end()) + cmTargetInternals::OptionalLinkInterface& + iface = this->Internal->LinkInterfaceMap[key]; + if(!iface.LibrariesDone) { - // Compute the link interface for this configuration. - cmTargetInternals::OptionalLinkInterface iface; + iface.LibrariesDone = true; iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, iface, head, false, iface.Exists); - if (iface.Exists) + } + if(!iface.AllDone) + { + iface.AllDone = true; + if(iface.Exists) { this->Internal->ComputeLinkInterface(this, config, iface, head, iface.ExplicitLibraries); } - - // Store the information for this configuration. - cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); - i = this->Internal->LinkInterfaceMap.insert(entry).first; - } - else if(!i->second.Complete && i->second.Exists) - { - this->Internal->ComputeLinkInterface(this, config, i->second, head, - i->second.ExplicitLibraries); } - return i->second.Exists ? &i->second : 0; + return iface.Exists? &iface : 0; } //---------------------------------------------------------------------------- @@ -5950,22 +5946,17 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, this->Internal->LinkInterfaceUsageRequirementsOnlyMap : this->Internal->LinkInterfaceMap); - cmTargetInternals::LinkInterfaceMapType::iterator i = lim.find(key); - if(i == lim.end()) + cmTargetInternals::OptionalLinkInterface& iface = lim[key]; + if(!iface.LibrariesDone) { - // Compute the link interface for this configuration. - cmTargetInternals::OptionalLinkInterface iface; + iface.LibrariesDone = true; iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, iface, head, usage_requirements_only, iface.Exists); - - // Store the information for this configuration. - cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); - i = lim.insert(entry).first; } - return i->second.Exists ? &i->second : 0; + return iface.Exists? &iface : 0; } //---------------------------------------------------------------------------- @@ -6348,7 +6339,6 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, sscanf(reps, "%u", &iface.Multiplicity); } } - iface.Complete = true; } //---------------------------------------------------------------------------- From b0f57408512b194923b6c9e5e79a08bc324c552e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 17:05:35 -0400 Subject: [PATCH 6/8] cmTarget: Move ComputeLinkInterfaceLibraries to internals There are no external callers, and this will allow the method to see the full OptionalLinkInterface internal structure. --- Source/cmTarget.cxx | 95 +++++++++++++++++++++++++-------------------- Source/cmTarget.h | 6 --- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3361a8142..663b15e90 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -124,6 +124,12 @@ public: OptionalLinkInterface& iface, cmTarget const* head, const char *explicitLibraries) const; + const char* ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only, + bool &exists); typedef std::map LinkInterfaceMapType; @@ -5903,8 +5909,8 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( { iface.LibrariesDone = true; iface.ExplicitLibraries = - this->ComputeLinkInterfaceLibraries(config, iface, head, false, - iface.Exists); + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, false, iface.Exists); } if(!iface.AllDone) { @@ -5951,9 +5957,8 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, { iface.LibrariesDone = true; iface.ExplicitLibraries = - this->ComputeLinkInterfaceLibraries(config, iface, head, - usage_requirements_only, - iface.Exists); + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, usage_requirements_only, iface.Exists); } return iface.Exists? &iface : 0; @@ -6076,11 +6081,14 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, } //---------------------------------------------------------------------------- -const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, - LinkInterface& iface, - cmTarget const* headTarget, - bool usage_requirements_only, - bool &exists) const +const char* +cmTargetInternals::ComputeLinkInterfaceLibraries( + cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + bool usage_requirements_only, + bool &exists) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -6097,15 +6105,15 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, // libraries and executables that export symbols. const char* explicitLibraries = 0; std::string linkIfaceProp; - if(this->PolicyStatusCMP0022 != cmPolicies::OLD && - this->PolicyStatusCMP0022 != cmPolicies::WARN) + if(thisTarget->PolicyStatusCMP0022 != cmPolicies::OLD && + thisTarget->PolicyStatusCMP0022 != cmPolicies::WARN) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp); + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); } - else if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->IsExecutableWithExports()) + else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || + thisTarget->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -6113,31 +6121,32 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = this->GetProperty(linkIfaceProp); + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp); + explicitLibraries = thisTarget->GetProperty(linkIfaceProp); } } - if(explicitLibraries && this->PolicyStatusCMP0022 == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022) + if(explicitLibraries && + thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN && + !this->PolicyWarnedCMP0022) { // Compare the explicitly set old link interface properties to the // preferred new link interface property one and warn if different. const char* newExplicitLibraries = - this->GetProperty("INTERFACE_LINK_LIBRARIES"); + thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES"); if (newExplicitLibraries && strcmp(newExplicitLibraries, explicitLibraries) != 0) { cmOStringStream w; w << - (this->Makefile->GetPolicies() + (thisTarget->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" - "Target \"" << this->GetName() << "\" has an " + "Target \"" << thisTarget->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property which differs from its " << linkIfaceProp << " properties." "\n" @@ -6145,16 +6154,16 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, " " << newExplicitLibraries << "\n" << linkIfaceProp << ":\n" " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->Internal->PolicyWarnedCMP0022 = true; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; } } // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. if(!explicitLibraries && - (this->GetType() == cmTarget::EXECUTABLE || - (this->GetType() == cmTarget::MODULE_LIBRARY))) + (thisTarget->GetType() == cmTarget::EXECUTABLE || + (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) { exists = false; return 0; @@ -6164,34 +6173,34 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, if(explicitLibraries) { // The interface libraries have been explicitly set. - this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, usage_requirements_only, - iface.Libraries); + thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, + headTarget, usage_requirements_only, + iface.Libraries); } - else if (this->PolicyStatusCMP0022 == cmPolicies::WARN - || this->PolicyStatusCMP0022 == cmPolicies::OLD) + else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN + || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back // to the link implementation. { // The link implementation is the default link interface. - LinkImplementation const* impl = - this->GetLinkImplementationLibrariesInternal(config, headTarget); + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); std::copy(impl->Libraries.begin(), impl->Libraries.end(), std::back_inserter(iface.Libraries)); - if(this->PolicyStatusCMP0022 == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022 && !usage_requirements_only) + if(thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN && + !this->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. std::vector ifaceLibs; std::string newProp = "INTERFACE_LINK_LIBRARIES"; - if(const char* newExplicitLibraries = this->GetProperty(newProp)) + if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp)) { - this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, usage_requirements_only, - ifaceLibs); + thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config, + headTarget, usage_requirements_only, + ifaceLibs); } if (ifaceLibs != iface.Libraries) { @@ -6220,9 +6229,9 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, cmOStringStream w; w << - (this->Makefile->GetPolicies() + (thisTarget->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" - "Target \"" << this->GetName() << "\" has an " + "Target \"" << thisTarget->GetName() << "\" has an " "INTERFACE_LINK_LIBRARIES property. " "This should be preferred as the source of the link interface " "for this library but because CMP0022 is not set CMake is " @@ -6233,8 +6242,8 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, " " << newLibraries << "\n" "Link implementation:\n" " " << oldLibraries << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - this->Internal->PolicyWarnedCMP0022 = true; + thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->PolicyWarnedCMP0022 = true; } } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 39a0667a6..aa18590c4 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -771,12 +771,6 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; - const char* ComputeLinkInterfaceLibraries(const std::string& config, - LinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only, - bool &exists) const; - LinkImplementation const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; From 102eea60cd636e06ab87bc94a4b326682d7464f1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 10 Jul 2014 17:15:39 -0400 Subject: [PATCH 7/8] cmTarget: Simplify internal ComputeLinkInterfaceLibraries method Now that the method can see the full OptionalLinkInterface structure, store information there instead of passing it through arguments. --- Source/cmTarget.cxx | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 663b15e90..826a44b5f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -122,14 +122,12 @@ public: void ComputeLinkInterface(cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, - cmTarget const* head, - const char *explicitLibraries) const; - const char* ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, - const std::string& config, - OptionalLinkInterface& iface, - cmTarget const* head, - bool usage_requirements_only, - bool &exists); + cmTarget const* head) const; + void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + bool usage_requirements_only); typedef std::map LinkInterfaceMapType; @@ -5908,17 +5906,15 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( if(!iface.LibrariesDone) { iface.LibrariesDone = true; - iface.ExplicitLibraries = - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, false, iface.Exists); + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, false); } if(!iface.AllDone) { iface.AllDone = true; if(iface.Exists) { - this->Internal->ComputeLinkInterface(this, config, iface, - head, iface.ExplicitLibraries); + this->Internal->ComputeLinkInterface(this, config, iface, head); } } @@ -5956,9 +5952,8 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, if(!iface.LibrariesDone) { iface.LibrariesDone = true; - iface.ExplicitLibraries = - this->Internal->ComputeLinkInterfaceLibraries( - this, config, iface, head, usage_requirements_only, iface.Exists); + this->Internal->ComputeLinkInterfaceLibraries( + this, config, iface, head, usage_requirements_only); } return iface.Exists? &iface : 0; @@ -6081,14 +6076,13 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, } //---------------------------------------------------------------------------- -const char* +void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, cmTarget const* headTarget, - bool usage_requirements_only, - bool &exists) + bool usage_requirements_only) { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -6165,10 +6159,10 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( (thisTarget->GetType() == cmTarget::EXECUTABLE || (thisTarget->GetType() == cmTarget::MODULE_LIBRARY))) { - exists = false; - return 0; + return; } - exists = true; + iface.Exists = true; + iface.ExplicitLibraries = explicitLibraries; if(explicitLibraries) { @@ -6247,17 +6241,15 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( } } } - return explicitLibraries; } //---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, const std::string& config, OptionalLinkInterface& iface, - cmTarget const* headTarget, - const char* explicitLibraries) const + cmTarget const* headTarget) const { - if(explicitLibraries) + if(iface.ExplicitLibraries) { if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY || thisTarget->GetType() == cmTarget::STATIC_LIBRARY From 1ca0c0e94ac39c895d5896b0193cbc7b963ff087 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 14 Jul 2014 10:21:24 -0400 Subject: [PATCH 8/8] cmTarget: Refactor internal imported LinkInterface map Create the map entry up front and store in it a boolean value indicating whether the LinkInterface structure has been populated. This approach leads to shorter code that is easier to follow too. --- Source/cmTarget.cxx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 826a44b5f..79be1db8f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -135,7 +135,7 @@ public: LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; bool PolicyWarnedCMP0022; - typedef std::map + typedef std::map ImportLinkInterfaceMapType; ImportLinkInterfaceMapType ImportLinkInterfaceMap; ImportLinkInterfaceMapType ImportLinkInterfaceUsageRequirementsOnlyMap; @@ -5977,26 +5977,21 @@ cmTarget::GetImportLinkInterface(const std::string& config, this->Internal->ImportLinkInterfaceUsageRequirementsOnlyMap : this->Internal->ImportLinkInterfaceMap); - cmTargetInternals::ImportLinkInterfaceMapType::iterator i = lim.find(key); - if(i == lim.end()) + cmTargetInternals::OptionalLinkInterface& iface = lim[key]; + if(!iface.AllDone) { - LinkInterface iface; + iface.AllDone = true; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries); - { std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); this->LookupLinkItems(deps, iface.SharedDeps); } - cmTargetInternals::ImportLinkInterfaceMapType::value_type - entry(key, iface); - i = lim.insert(entry).first; - } - return &i->second; + return &iface; } //----------------------------------------------------------------------------