cmTarget: De-duplicate link interface evaluation for $<LINK_ONLY>

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.
This commit is contained in:
Brad King 2014-06-16 14:27:42 -04:00
parent 6ead631bf9
commit 0192be5181
1 changed files with 12 additions and 32 deletions

View File

@ -6219,15 +6219,18 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config,
cmTarget const* headTarget, cmTarget const* headTarget,
std::vector<cmTarget const*> &tgts) const std::vector<cmTarget const*> &tgts) const
{ {
cmTarget::LinkInterface const* iface // The $<LINK_ONLY> expression may be in a link interface to specify private
= this->GetLinkInterfaceLibraries(config, headTarget, false); // link dependencies that are otherwise excluded from usage requirements.
if (!iface) // Currently $<LINK_ONLY> is internal to CMake and only ever added by
{ // target_link_libraries for PRIVATE dependencies of STATIC libraries in
return; // INTERFACE_LINK_LIBRARIES which is used under CMP0022 NEW behavior.
} bool usage_requirements_only =
if(this->GetType() != STATIC_LIBRARY this->GetType() == STATIC_LIBRARY &&
|| this->GetPolicyStatusCMP0022() == cmPolicies::WARN this->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
|| this->GetPolicyStatusCMP0022() == cmPolicies::OLD) this->GetPolicyStatusCMP0022() != cmPolicies::OLD;
if(cmTarget::LinkInterface const* iface =
this->GetLinkInterfaceLibraries(config, headTarget,
usage_requirements_only))
{ {
for(std::vector<cmLinkItem>::const_iterator it = iface->Libraries.begin(); for(std::vector<cmLinkItem>::const_iterator it = iface->Libraries.begin();
it != iface->Libraries.end(); ++it) it != iface->Libraries.end(); ++it)
@ -6237,29 +6240,6 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config,
tgts.push_back(it->Target); 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<cmLinkItem> libs;
this->ExpandLinkItems(linkIfaceProp, interfaceLibs, config,
headTarget, true, libs);
for(std::vector<cmLinkItem>::const_iterator it = libs.begin();
it != libs.end(); ++it)
{
if (it->Target)
{
tgts.push_back(it->Target);
}
} }
} }