From 0dc9e88d76fa74440fc3b38032738a21ce72f2d7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 12 Jun 2014 16:22:11 -0400 Subject: [PATCH] cmTarget: Remove 'head' argument from GetLinkImplementation Many of the 'head' arguments added by commit v2.8.11~289^2~1 (Make linking APIs aware of 'head' target, 2013-01-04) turned out not to be needed. The "link implementation" of a target never needs to be computed with anything but itself as the 'head' target (except for CMP0022 OLD behavior because then it is the link interface). Remove the unused 'head' target paths. Add "internal" versions of cmTarget::GetDirectLinkLibraries and GetLinkImplementationLibraries to support the CMP0022 OLD behavior without otherwise exposing the 'head' target option of these methods. --- Source/cmComputeLinkDepends.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 2 +- Source/cmGeneratorExpressionEvaluator.cxx | 3 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmTarget.cxx | 53 ++++++++++++++--------- Source/cmTarget.h | 18 +++++--- 7 files changed, 49 insertions(+), 33 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 1aabdebe5..1b83ee8fa 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -542,7 +542,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config, this->Target); + this->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 8e75807a8..a5df060bc 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -250,7 +250,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } } std::vector tlibs; - depender->GetDirectLinkLibraries(*it, tlibs, depender); + depender->GetDirectLinkLibraries(*it, tlibs); // A target should not depend on itself. emitted.insert(depender->GetName()); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 7dcb335d6..cefdd6316 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1098,8 +1098,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmStrCmp(interfacePropertyName)) != transEnd) { const cmTarget::LinkImplementation *impl - = target->GetLinkImplementationLibraries(context->Config, - headTarget); + = target->GetLinkImplementationLibraries(context->Config); if(impl) { linkedTargetsContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7576ed60..381a0ed00 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -449,7 +449,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, if (iter == this->SystemIncludesCache.end()) { cmTarget::LinkImplementation const* impl - = this->Target->GetLinkImplementation(config, this->Target); + = this->Target->GetLinkImplementation(config); if(!impl) { return false; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 29a5955a6..9a36df5aa 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1255,7 +1255,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // If the language is compiled as a source trust Xcode to link with it. cmTarget::LinkImplementation const* impl = - cmtarget.GetLinkImplementation("NOCONFIG", &cmtarget); + cmtarget.GetLinkImplementation("NOCONFIG"); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f38005271..86cab4e8f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1198,8 +1198,15 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) const //---------------------------------------------------------------------------- void cmTarget::GetDirectLinkLibraries(const std::string& config, - std::vector &libs, - cmTarget const* head) const + std::vector &libs) const +{ + this->GetDirectLinkLibrariesInternal(config, libs, this); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetDirectLinkLibrariesInternal(const std::string& config, + std::vector &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("LINK_LIBRARIES"); if (prop) @@ -2273,8 +2280,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const if(this->Makefile->IsOn("APPLE")) { - LinkImplementation const* impl = this->GetLinkImplementation(config, - this); + LinkImplementation const* impl = this->GetLinkImplementation(config); for(std::vector::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) @@ -3632,7 +3638,7 @@ void cmTarget::ComputeLinkClosure(const std::string& config, { // Get languages built in this target. std::set languages; - LinkImplementation const* impl = this->GetLinkImplementation(config, this); + LinkImplementation const* impl = this->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { @@ -4500,7 +4506,7 @@ bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const return false; } std::vector libs; - this->GetDirectLinkLibraries(config, libs, this); + this->GetDirectLinkLibraries(config, libs); return !libs.empty(); } @@ -6151,7 +6157,7 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const std::set emitted; cmTarget::LinkImplementation const* impl - = this->GetLinkImplementationLibraries(config, this); + = this->GetLinkImplementationLibraries(config); for(std::vector::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) @@ -6321,7 +6327,7 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, { // The link implementation is the default link interface. LinkImplementation const* impl = - this->GetLinkImplementationLibraries(config, headTarget); + this->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries = impl->Libraries; if(this->PolicyStatusCMP0022 == cmPolicies::WARN && !this->Internal->PolicyWarnedCMP0022) @@ -6407,7 +6413,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) { cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config, headTarget); + thisTarget->GetLinkImplementation(config); for(std::vector::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { @@ -6438,7 +6444,8 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, { // The link implementation is the default link interface. cmTarget::LinkImplementation const* - impl = thisTarget->GetLinkImplementation(config, headTarget); + impl = thisTarget->GetLinkImplementationLibrariesInternal(config, + headTarget); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } @@ -6447,7 +6454,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, { // Targets using this archive need its language runtime libraries. if(cmTarget::LinkImplementation const* impl = - thisTarget->GetLinkImplementation(config, headTarget)) + thisTarget->GetLinkImplementation(config)) { iface.Languages = impl->Languages; } @@ -6485,8 +6492,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementation(const std::string& config, - cmTarget const* head) const +cmTarget::GetLinkImplementation(const std::string& config) const { // There is no link implementation for imported targets. if(this->IsImported()) @@ -6495,7 +6501,7 @@ cmTarget::GetLinkImplementation(const std::string& config, } // Lookup any existing link implementation for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config)); + TargetConfigPair key(this, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkImplMapType::iterator i = this->Internal->LinkImplMap.find(key); @@ -6503,8 +6509,8 @@ cmTarget::GetLinkImplementation(const std::string& config, { // Compute the link implementation for this configuration. LinkImplementation impl; - this->ComputeLinkImplementation(config, impl, head); - this->ComputeLinkImplementationLanguages(config, impl, head); + this->ComputeLinkImplementation(config, impl, this); + this->ComputeLinkImplementationLanguages(config, impl, this); // Store the information for this configuration. cmTargetInternals::LinkImplMapType::value_type entry(key, impl); @@ -6512,7 +6518,7 @@ cmTarget::GetLinkImplementation(const std::string& config, } else if (i->second.Languages.empty()) { - this->ComputeLinkImplementationLanguages(config, i->second, head); + this->ComputeLinkImplementationLanguages(config, i->second, this); } return &i->second; @@ -6520,8 +6526,15 @@ cmTarget::GetLinkImplementation(const std::string& config, //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementationLibraries(const std::string& config, - cmTarget const* head) const +cmTarget::GetLinkImplementationLibraries(const std::string& config) const +{ + return this->GetLinkImplementationLibrariesInternal(config, this); +} + +//---------------------------------------------------------------------------- +cmTarget::LinkImplementation const* +cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, + cmTarget const* head) const { // There is no link implementation for imported targets. if(this->IsImported()) @@ -6555,7 +6568,7 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, { // Collect libraries directly linked in this configuration. std::vector llibs; - this->GetDirectLinkLibraries(config, llibs, head); + this->GetDirectLinkLibrariesInternal(config, llibs, head); for(std::vector::const_iterator li = llibs.begin(); li != llibs.end(); ++li) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c6955e76..8cf962ff6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -158,8 +158,7 @@ public: const LinkLibraryVectorType &GetOriginalLinkLibraries() const {return this->OriginalLinkLibraries;} void GetDirectLinkLibraries(const std::string& config, - std::vector &, - cmTarget const* head) const; + std::vector &) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const std::string& config) const; @@ -291,12 +290,11 @@ public: // Needed only for OLD behavior of CMP0003. std::vector WrongConfigLibraries; }; - LinkImplementation const* GetLinkImplementation(const std::string& config, - cmTarget const* head) const; + LinkImplementation const* + GetLinkImplementation(const std::string& config) const; - LinkImplementation const* GetLinkImplementationLibraries( - const std::string& config, - cmTarget const* head) const; + LinkImplementation const* + GetLinkImplementationLibraries(const std::string& config) const; /** Link information from the transitive closure of the link implementation and the interfaces of its dependencies. */ @@ -750,6 +748,12 @@ private: cmTarget const* head, bool &exists) const; + void GetDirectLinkLibrariesInternal(const std::string& config, + std::vector& libs, + cmTarget const* head) const; + LinkImplementation const* + GetLinkImplementationLibrariesInternal(const std::string& config, + cmTarget const* head) const; void ComputeLinkImplementation(const std::string& config, LinkImplementation& impl, cmTarget const* head) const;