From 0192be51819f8765131fc059b3ee210011eb7b80 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Jun 2014 14:27:42 -0400 Subject: [PATCH] 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 325357d48..cb52e1529 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); - } } }