From 1001490df27f3ab93f8a37a6f6c3b33aa26d22e2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jun 2014 14:23:22 -0400 Subject: cmTarget: Teach ExpandLinkItems how to support $ Add a 'usage_requirements_only' parameter to ExpandLinkItems so that it knows whether to use SetTransitivePropertiesOnly while evaluating generator expressions. Update existing call sites to pass 'false' since they are for linking and not usage requirements. --- Source/cmTarget.cxx | 11 ++++++++--- Source/cmTarget.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 71d03df..32948cd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3688,10 +3688,15 @@ void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, std::vector& items) const { cmGeneratorExpression ge; cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0); + if(usage_requirements_only) + { + dagChecker.SetTransitivePropertiesOnly(); + } std::vector libs; cmSystemTools::ExpandListArgument(ge.Parse(value)->Evaluate( this->Makefile, @@ -6135,7 +6140,7 @@ cmTarget::GetImportLinkInterface(const std::string& config, iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, iface.Libraries); + headTarget, false, iface.Libraries); { std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); @@ -6341,7 +6346,7 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, { // The interface libraries have been explicitly set. this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, iface.Libraries); + headTarget, false, iface.Libraries); } else if (this->PolicyStatusCMP0022 == cmPolicies::WARN || this->PolicyStatusCMP0022 == cmPolicies::OLD) @@ -6364,7 +6369,7 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, if(const char* newExplicitLibraries = this->GetProperty(newProp)) { this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, ifaceLibs); + headTarget, false, ifaceLibs); } if (ifaceLibs != impl->Libraries) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3f534f2..4930d70 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -777,6 +777,7 @@ private: void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, + bool usage_requirements_only, std::vector& items) const; void LookupLinkItems(std::vector const& names, std::vector& items) const; -- cgit v0.12 From b030a7f1ca89620ad4b51569c991a7c0b8aa05c2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jun 2014 14:25:40 -0400 Subject: cmTarget: De-duplicate link interface genex code for $ Simplify the implementation of GetTransitivePropertyTargets by using ExpandLinkItems with usage_requirements_only==true to evaluate the generator expressions in the link interface for us. --- Source/cmTarget.cxx | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 32948cd..c4fd924 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6235,24 +6235,16 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, } // The interface libraries have been explicitly set. - cmGeneratorExpression ge; - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - linkIfaceProp, 0, 0); - dagChecker.SetTransitivePropertiesOnly(); - std::vector libs; - cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), libs); + std::vector libs; + this->ExpandLinkItems(linkIfaceProp, interfaceLibs, config, + headTarget, true, libs); - for(std::vector::const_iterator it = libs.begin(); + for(std::vector::const_iterator it = libs.begin(); it != libs.end(); ++it) { - if (cmTarget const* tgt = this->FindTargetToLink(*it)) + if (it->Target) { - tgts.push_back(tgt); + tgts.push_back(it->Target); } } } -- cgit v0.12 From 6ead631bf9ec6da8eeca5fb39e5eba80e5022f15 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jun 2014 14:27:42 -0400 Subject: cmTarget: Teach GetLinkInterfaceLibraries to support $ Add a 'usage_requirements_only' parameter to GetLinkInterfaceLibraries and supporting internal APIs to pass through to ExpandLinkItems so it knows whether to use SetTransitivePropertiesOnly while evaluating generator expressions. --- Source/cmTarget.cxx | 63 ++++++++++++++++++++++++++++++++++------------------- Source/cmTarget.h | 8 ++++--- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c4fd924..325357d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,11 +126,13 @@ public: typedef std::map LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; + LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; bool PolicyWarnedCMP0022; typedef std::map ImportLinkInterfaceMapType; ImportLinkInterfaceMapType ImportLinkInterfaceMap; + ImportLinkInterfaceMapType ImportLinkInterfaceUsageRequirementsOnlyMap; typedef std::map OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -510,7 +512,9 @@ void cmTarget::ClearLinkMaps() this->LinkImplementationLanguageIsContextDependent = true; this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); + this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->ImportLinkInterfaceMap.clear(); + this->Internal->ImportLinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); for (cmTargetLinkInformationMap::const_iterator it = this->LinkInformation.begin(); @@ -6037,7 +6041,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( // Imported targets have their own link interface. if(this->IsImported()) { - return this->GetImportLinkInterface(config, head); + return this->GetImportLinkInterface(config, head, false); } // Link interfaces are not supported for executables that do not @@ -6058,7 +6062,8 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( // Compute the link interface for this configuration. cmTargetInternals::OptionalLinkInterface iface; iface.ExplicitLibraries = - this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists); + this->ComputeLinkInterfaceLibraries(config, iface, head, false, + iface.Exists); if (iface.Exists) { this->Internal->ComputeLinkInterface(this, config, iface, @@ -6081,12 +6086,13 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface( //---------------------------------------------------------------------------- cmTarget::LinkInterface const* cmTarget::GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* head) const + cmTarget const* head, + bool usage_requirements_only) const { // Imported targets have their own link interface. if(this->IsImported()) { - return this->GetImportLinkInterface(config, head); + return this->GetImportLinkInterface(config, head, usage_requirements_only); } // Link interfaces are not supported for executables that do not @@ -6099,21 +6105,24 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, // Lookup any existing link interface for this configuration. TargetConfigPair key(head, cmSystemTools::UpperCase(config)); + cmTargetInternals::LinkInterfaceMapType& lim = + (usage_requirements_only ? + this->Internal->LinkInterfaceUsageRequirementsOnlyMap : + this->Internal->LinkInterfaceMap); - cmTargetInternals::LinkInterfaceMapType::iterator - i = this->Internal->LinkInterfaceMap.find(key); - if(i == this->Internal->LinkInterfaceMap.end()) + cmTargetInternals::LinkInterfaceMapType::iterator i = lim.find(key); + if(i == lim.end()) { // Compute the link interface for this configuration. cmTargetInternals::OptionalLinkInterface iface; - iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, - iface, - head, - iface.Exists); + 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 = this->Internal->LinkInterfaceMap.insert(entry).first; + i = lim.insert(entry).first; } return i->second.Exists ? &i->second : 0; @@ -6122,7 +6131,8 @@ cmTarget::GetLinkInterfaceLibraries(const std::string& config, //---------------------------------------------------------------------------- cmTarget::LinkInterface const* cmTarget::GetImportLinkInterface(const std::string& config, - cmTarget const* headTarget) const + cmTarget const* headTarget, + bool usage_requirements_only) const { cmTarget::ImportInfo const* info = this->GetImportInfo(config); if(!info) @@ -6131,16 +6141,20 @@ cmTarget::GetImportLinkInterface(const std::string& config, } TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config)); + cmTargetInternals::ImportLinkInterfaceMapType& lim = + (usage_requirements_only ? + this->Internal->ImportLinkInterfaceUsageRequirementsOnlyMap : + this->Internal->ImportLinkInterfaceMap); - cmTargetInternals::ImportLinkInterfaceMapType::iterator i = - this->Internal->ImportLinkInterfaceMap.find(key); - if(i == this->Internal->ImportLinkInterfaceMap.end()) + cmTargetInternals::ImportLinkInterfaceMapType::iterator i = lim.find(key); + if(i == lim.end()) { LinkInterface iface; iface.Multiplicity = info->Multiplicity; cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, - headTarget, false, iface.Libraries); + headTarget, usage_requirements_only, + iface.Libraries); { std::vector deps; cmSystemTools::ExpandListArgument(info->SharedDeps, deps); @@ -6149,7 +6163,7 @@ cmTarget::GetImportLinkInterface(const std::string& config, cmTargetInternals::ImportLinkInterfaceMapType::value_type entry(key, iface); - i = this->Internal->ImportLinkInterfaceMap.insert(entry).first; + i = lim.insert(entry).first; } return &i->second; } @@ -6165,7 +6179,7 @@ void processILibs(const std::string& config, { tgts.push_back(item.Target); if(cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget)) + item.Target->GetLinkInterfaceLibraries(config, headTarget, false)) { for(std::vector::const_iterator it = iface->Libraries.begin(); @@ -6206,7 +6220,7 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, std::vector &tgts) const { cmTarget::LinkInterface const* iface - = this->GetLinkInterfaceLibraries(config, headTarget); + = this->GetLinkInterfaceLibraries(config, headTarget, false); if (!iface) { return; @@ -6253,6 +6267,7 @@ 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 { // Construct the property name suffix for this configuration. @@ -6338,7 +6353,8 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, { // The interface libraries have been explicitly set. this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, - headTarget, false, iface.Libraries); + headTarget, usage_requirements_only, + iface.Libraries); } else if (this->PolicyStatusCMP0022 == cmPolicies::WARN || this->PolicyStatusCMP0022 == cmPolicies::OLD) @@ -6352,7 +6368,7 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, this->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries = impl->Libraries; if(this->PolicyStatusCMP0022 == cmPolicies::WARN && - !this->Internal->PolicyWarnedCMP0022) + !this->Internal->PolicyWarnedCMP0022 && !usage_requirements_only) { // Compare the link implementation fallback link interface to the // preferred new link interface property and warn if different. @@ -6361,7 +6377,8 @@ const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, if(const char* newExplicitLibraries = this->GetProperty(newProp)) { this->ExpandLinkItems(newProp, newExplicitLibraries, config, - headTarget, false, ifaceLibs); + headTarget, usage_requirements_only, + ifaceLibs); } if (ifaceLibs != impl->Libraries) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4930d70..9d1f966 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -280,7 +280,8 @@ public: LinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; LinkInterface const* GetLinkInterfaceLibraries(const std::string& config, - cmTarget const* headTarget) const; + cmTarget const* headTarget, + bool usage_requirements_only) const; void GetTransitivePropertyTargets(const std::string& config, cmTarget const* headTarget, std::vector &libs) const; @@ -756,12 +757,13 @@ private: const std::string& config) const; LinkInterface const* - GetImportLinkInterface(const std::string& config, - cmTarget const* head) const; + 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* -- cgit v0.12 From 0192be51819f8765131fc059b3ee210011eb7b80 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jun 2014 14:27:42 -0400 Subject: cmTarget: De-duplicate link interface evaluation for $ Teach GetTransitivePropertyTargets to use the GetLinkInterfaceLibraries method with usage_requirements_only==true instead of evaluating the INTERFACE_LINK_LIBRARIES property directly. This avoids duplicate evaluations and makes use of the caching done by GetLinkInterfaceLibraries. --- Source/cmTarget.cxx | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 325357d..cb52e15 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6219,15 +6219,18 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, cmTarget const* headTarget, std::vector &tgts) const { - cmTarget::LinkInterface const* iface - = this->GetLinkInterfaceLibraries(config, headTarget, false); - if (!iface) - { - return; - } - if(this->GetType() != STATIC_LIBRARY - || this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // The $ expression may be in a link interface to specify private + // link dependencies that are otherwise excluded from usage requirements. + // Currently $ is internal to CMake and only ever added by + // target_link_libraries for PRIVATE dependencies of STATIC libraries in + // INTERFACE_LINK_LIBRARIES which is used under CMP0022 NEW behavior. + bool usage_requirements_only = + this->GetType() == STATIC_LIBRARY && + this->GetPolicyStatusCMP0022() != cmPolicies::WARN && + this->GetPolicyStatusCMP0022() != cmPolicies::OLD; + if(cmTarget::LinkInterface const* iface = + this->GetLinkInterfaceLibraries(config, headTarget, + usage_requirements_only)) { for(std::vector::const_iterator it = iface->Libraries.begin(); it != iface->Libraries.end(); ++it) @@ -6237,29 +6240,6 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config, tgts.push_back(it->Target); } } - return; - } - - const char* linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - const char* interfaceLibs = this->GetProperty(linkIfaceProp); - - if (!interfaceLibs) - { - return; - } - - // The interface libraries have been explicitly set. - std::vector libs; - this->ExpandLinkItems(linkIfaceProp, interfaceLibs, config, - headTarget, true, libs); - - for(std::vector::const_iterator it = libs.begin(); - it != libs.end(); ++it) - { - if (it->Target) - { - tgts.push_back(it->Target); - } } } -- cgit v0.12 From b8651d970d06325b9ad5166295e3bbc25052a8fd Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jun 2014 13:36:09 -0400 Subject: cmTarget: Remove unnecessary 'mutable' markup Members of the cmTargetInternals structure do not need to be made 'mutable' even to cache data because there is no reason for the internal methods to be 'const'. --- Source/cmTarget.cxx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cb52e15..c8b1690 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -174,25 +174,25 @@ public: std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; - mutable std::map > - CachedLinkInterfaceIncludeDirectoriesEntries; - mutable std::map > - CachedLinkInterfaceCompileOptionsEntries; - mutable std::map > - CachedLinkInterfaceCompileDefinitionsEntries; - mutable std::map > - CachedLinkInterfaceSourcesEntries; - mutable std::map > - CachedLinkInterfaceCompileFeaturesEntries; - mutable std::map > - CachedLinkImplementationClosure; - - mutable std::map CacheLinkInterfaceIncludeDirectoriesDone; - mutable std::map CacheLinkInterfaceCompileDefinitionsDone; - mutable std::map CacheLinkInterfaceCompileOptionsDone; - mutable std::map CacheLinkInterfaceSourcesDone; - mutable std::map CacheLinkInterfaceCompileFeaturesDone; - mutable std::map CacheLinkImplementationClosureDone; + std::map > + CachedLinkInterfaceIncludeDirectoriesEntries; + std::map > + CachedLinkInterfaceCompileOptionsEntries; + std::map > + CachedLinkInterfaceCompileDefinitionsEntries; + std::map > + CachedLinkInterfaceSourcesEntries; + std::map > + CachedLinkInterfaceCompileFeaturesEntries; + std::map > + CachedLinkImplementationClosure; + + std::map CacheLinkInterfaceIncludeDirectoriesDone; + std::map CacheLinkInterfaceCompileDefinitionsDone; + std::map CacheLinkInterfaceCompileOptionsDone; + std::map CacheLinkInterfaceSourcesDone; + std::map CacheLinkInterfaceCompileFeaturesDone; + std::map CacheLinkImplementationClosureDone; }; //---------------------------------------------------------------------------- -- cgit v0.12 From 7b0834e9bbe614670552036b14c7556a3c76c9a9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jun 2014 10:45:08 -0400 Subject: cmTarget: Refactor internal LinkImplementation map If ComputeLinkImplementationLanguages were ever to cause GetLinkImplementationLibraries to be invoked then a LinkImplMap entry may appear in the middle of computing it in GetLinkInformation. Instead create the map entry up front and store in it boolean values indicating which pieces of the LinkImplementation structure have been populated. This approach leads to shorter code that is easier to follow too. --- Source/cmTarget.cxx | 55 +++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c8b1690..5bb15f5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -144,8 +144,15 @@ public: CompileInfoMapType CompileInfoMap; // Cache link implementation computation from each configuration. + struct OptionalLinkImplementation: public cmTarget::LinkImplementation + { + OptionalLinkImplementation(): + LibrariesDone(false), LanguagesDone(false) {} + bool LibrariesDone; + bool LanguagesDone; + }; typedef std::map LinkImplMapType; + OptionalLinkImplementation> LinkImplMapType; LinkImplMapType LinkImplMap; typedef std::map LinkClosureMapType; @@ -6519,28 +6526,21 @@ cmTarget::GetLinkImplementation(const std::string& config) const return 0; } - // Lookup any existing link implementation for this configuration. + // Populate the link implementation for this configuration. TargetConfigPair key(this, cmSystemTools::UpperCase(config)); - - cmTargetInternals::LinkImplMapType::iterator - i = this->Internal->LinkImplMap.find(key); - if(i == this->Internal->LinkImplMap.end()) + cmTargetInternals::OptionalLinkImplementation& + impl = this->Internal->LinkImplMap[key]; + if(!impl.LibrariesDone) { - // Compute the link implementation for this configuration. - LinkImplementation impl; + impl.LibrariesDone = true; this->ComputeLinkImplementation(config, impl, this); - this->ComputeLinkImplementationLanguages(config, impl, this); - - // Store the information for this configuration. - cmTargetInternals::LinkImplMapType::value_type entry(key, impl); - i = this->Internal->LinkImplMap.insert(entry).first; } - else if (i->second.Languages.empty()) + if(!impl.LanguagesDone) { - this->ComputeLinkImplementationLanguages(config, i->second, this); + impl.LanguagesDone = true; + this->ComputeLinkImplementationLanguages(config, impl, this); } - - return &i->second; + return &impl; } //---------------------------------------------------------------------------- @@ -6561,23 +6561,16 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, return 0; } - // Lookup any existing link implementation for this configuration. + // Populate the link implementation libraries for this configuration. TargetConfigPair key(head, cmSystemTools::UpperCase(config)); - - cmTargetInternals::LinkImplMapType::iterator - i = this->Internal->LinkImplMap.find(key); - if(i == this->Internal->LinkImplMap.end()) + cmTargetInternals::OptionalLinkImplementation& + impl = this->Internal->LinkImplMap[key]; + if(!impl.LibrariesDone) { - // Compute the link implementation for this configuration. - LinkImplementation impl; - this->ComputeLinkImplementation(config, impl, head); - - // Store the information for this configuration. - cmTargetInternals::LinkImplMapType::value_type entry(key, impl); - i = this->Internal->LinkImplMap.insert(entry).first; + impl.LibrariesDone = true; + this->ComputeLinkImplementation(config, impl, this); } - - return &i->second; + return &impl; } //---------------------------------------------------------------------------- -- cgit v0.12 From f48d8bd6f6bee4a24a3c716fc744f8dcdff7b399 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jun 2014 13:44:24 -0400 Subject: cmTarget: Shorten a long line in ComputeLinkImplementation Prepare to change its indentation without exceeding line length limit. --- Source/cmTarget.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5bb15f5..b418405 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6640,9 +6640,8 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, if(!noMessage) { e << "Target \"" << this->GetName() << "\" links to itself."; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->GetBacktrace()); + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); if (messageType == cmake::FATAL_ERROR) { return; -- cgit v0.12 From 7812d2a912ca596d3db9d28a9291e83a55ffe75c Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jun 2014 13:45:15 -0400 Subject: cmTarget: Pre-indent a block in ComputeLinkImplementation Prepare to move it into another block without extra whitespace changes. --- Source/cmTarget.cxx | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b418405..910d951 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6607,54 +6607,54 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); } - for(std::vector::const_iterator li = llibs.begin(); - li != llibs.end(); ++li) - { - // Skip entries that resolve to the target itself or are empty. - std::string name = this->CheckCMP0004(*li); - if(name == this->GetName() || name.empty()) + for(std::vector::const_iterator li = llibs.begin(); + li != llibs.end(); ++li) { - if(name == this->GetName()) + // Skip entries that resolve to the target itself or are empty. + std::string name = this->CheckCMP0004(*li); + if(name == this->GetName() || name.empty()) { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - cmOStringStream e; - switch(this->GetPolicyStatusCMP0038()) + if(name == this->GetName()) { - case cmPolicies::WARN: + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + switch(this->GetPolicyStatusCMP0038()) { - e << (this->Makefile->GetPolicies() - ->GetPolicyWarning(cmPolicies::CMP0038)) << "\n"; - messageType = cmake::AUTHOR_WARNING; + case cmPolicies::WARN: + { + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0038)) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - if(!noMessage) - { - e << "Target \"" << this->GetName() << "\" links to itself."; - this->Makefile->GetCMakeInstance()->IssueMessage( - messageType, e.str(), this->GetBacktrace()); - if (messageType == cmake::FATAL_ERROR) + if(!noMessage) { - return; + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } } } + continue; } - continue; - } - // The entry is meant for this configuration. - impl.Libraries.push_back( - cmLinkItem(name, this->FindTargetToLink(name))); - } + // The entry is meant for this configuration. + impl.Libraries.push_back( + cmLinkItem(name, this->FindTargetToLink(name))); + } cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); LinkLibraryVectorType const& oldllibs = this->GetOriginalLinkLibraries(); -- cgit v0.12 From 24637979962012ae170f7848ad69e896f8d3f67c Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 19 Jun 2014 13:48:28 -0400 Subject: cmTarget: Refactor ComputeLinkImplementation Use LinkImplementationPropertyEntries directly instead of asking GetProperty to construct a string for LINK_LIBRARIES. This gives us access to the entry backtraces. --- Source/cmTarget.cxx | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 910d951..aa0ed56 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -6579,15 +6579,18 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, cmTarget const* head) const { // Collect libraries directly linked in this configuration. - std::vector llibs; - if(const char *prop = this->GetProperty("LINK_LIBRARIES")) + for (std::vector::const_iterator + le = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); + le != end; ++le) { - cmGeneratorExpression ge; - const cmsys::auto_ptr cge = ge.Parse(prop); - + std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "LINK_LIBRARIES", 0, 0); + cmGeneratorExpression ge(&le->Backtrace); + cmsys::auto_ptr const cge = + ge.Parse(le->Value); cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config, false, @@ -6595,18 +6598,6 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, &dagChecker), llibs); - std::set const& seenProps = cge->GetSeenTargetProperties(); - for (std::set::const_iterator it = seenProps.begin(); - it != seenProps.end(); ++it) - { - if (!this->GetProperty(*it)) - { - this->LinkImplicitNullProperties.insert(*it); - } - } - cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); - } - for(std::vector::const_iterator li = llibs.begin(); li != llibs.end(); ++li) { @@ -6656,6 +6647,18 @@ void cmTarget::ComputeLinkImplementation(const std::string& config, cmLinkItem(name, this->FindTargetToLink(name))); } + std::set const& seenProps = cge->GetSeenTargetProperties(); + for (std::set::const_iterator it = seenProps.begin(); + it != seenProps.end(); ++it) + { + if (!this->GetProperty(*it)) + { + this->LinkImplicitNullProperties.insert(*it); + } + } + cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards); + } + cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); LinkLibraryVectorType const& oldllibs = this->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); -- cgit v0.12