cmTarget: Change GetTransitivePropertyLinkLibraries to output targets.
The callers already skip non-targets, so unify the target search. Change supporting functions to accept a container of targets instead of strings where possible.
This commit is contained in:
parent
f81eb49e8b
commit
21e91350b0
|
@ -800,7 +800,7 @@ static const char* targetPropertyTransitiveWhitelist[] = {
|
|||
|
||||
#undef TRANSITIVE_PROPERTY_NAME
|
||||
|
||||
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
||||
std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
|
||||
cmTarget const* target,
|
||||
cmTarget const* headTarget,
|
||||
cmGeneratorExpressionContext *context,
|
||||
|
@ -811,24 +811,22 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
|||
|
||||
std::string sep;
|
||||
std::string depString;
|
||||
for (std::vector<std::string>::const_iterator
|
||||
it = libraries.begin();
|
||||
it != libraries.end(); ++it)
|
||||
for (std::vector<cmTarget*>::const_iterator
|
||||
it = targets.begin();
|
||||
it != targets.end(); ++it)
|
||||
{
|
||||
if (*it == target->GetName())
|
||||
if (*it == target)
|
||||
{
|
||||
// Broken code can have a target in its own link interface.
|
||||
// Don't follow such link interface entries so as not to create a
|
||||
// self-referencing loop.
|
||||
continue;
|
||||
}
|
||||
if (context->Makefile->FindTargetToUse(*it))
|
||||
{
|
||||
depString +=
|
||||
sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">";
|
||||
sep + "$<TARGET_PROPERTY:" +
|
||||
(*it)->GetName() + "," + interfacePropertyName + ">";
|
||||
sep = ";";
|
||||
}
|
||||
}
|
||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
|
||||
std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
|
||||
context->Config,
|
||||
|
@ -843,6 +841,27 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
|||
return linkedTargetsContent;
|
||||
}
|
||||
|
||||
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
||||
cmTarget const* target,
|
||||
cmTarget const* headTarget,
|
||||
cmGeneratorExpressionContext *context,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||
const std::string &interfacePropertyName)
|
||||
{
|
||||
std::vector<cmTarget*> tgts;
|
||||
for (std::vector<std::string>::const_iterator
|
||||
it = libraries.begin();
|
||||
it != libraries.end(); ++it)
|
||||
{
|
||||
if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it))
|
||||
{
|
||||
tgts.push_back(tgt);
|
||||
}
|
||||
}
|
||||
return getLinkedTargetsContent(tgts, target, headTarget, context,
|
||||
dagChecker, interfacePropertyName);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||
{
|
||||
|
@ -1065,13 +1084,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|||
cmStrCmp(propertyName)) != transEnd)
|
||||
{
|
||||
|
||||
std::vector<std::string> libs;
|
||||
target->GetTransitivePropertyLinkLibraries(context->Config,
|
||||
headTarget, libs);
|
||||
if (!libs.empty())
|
||||
std::vector<cmTarget*> tgts;
|
||||
target->GetTransitivePropertyTargets(context->Config,
|
||||
headTarget, tgts);
|
||||
if (!tgts.empty())
|
||||
{
|
||||
linkedTargetsContent =
|
||||
getLinkedTargetsContent(libs, target,
|
||||
getLinkedTargetsContent(tgts, target,
|
||||
headTarget,
|
||||
context, &dagChecker,
|
||||
interfacePropertyName);
|
||||
|
|
|
@ -63,19 +63,12 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name,
|
||||
static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
|
||||
const char *config, cmTarget *headTarget,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||
std::vector<std::string>& result,
|
||||
bool excludeImported)
|
||||
{
|
||||
cmTarget* depTgt = mf->FindTargetToUse(name);
|
||||
|
||||
if (!depTgt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cmListFileBacktrace lfbt;
|
||||
|
||||
if (const char* dirs =
|
||||
|
@ -225,26 +218,25 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
|
|||
&dagChecker), result);
|
||||
}
|
||||
|
||||
std::set<cmStdString> uniqueDeps;
|
||||
std::set<cmTarget*> uniqueDeps;
|
||||
for(std::vector<std::string>::const_iterator li = impl->Libraries.begin();
|
||||
li != impl->Libraries.end(); ++li)
|
||||
{
|
||||
if (uniqueDeps.insert(*li).second)
|
||||
{
|
||||
cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
|
||||
|
||||
if (!tgt)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
handleSystemIncludesDep(this->Makefile, *li, config, this->Target,
|
||||
if (uniqueDeps.insert(tgt).second)
|
||||
{
|
||||
handleSystemIncludesDep(this->Makefile, tgt, config, this->Target,
|
||||
&dagChecker, result, excludeImported);
|
||||
|
||||
std::vector<std::string> deps;
|
||||
tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps);
|
||||
std::vector<cmTarget*> deps;
|
||||
tgt->GetTransitivePropertyTargets(config, this->Target, deps);
|
||||
|
||||
for(std::vector<std::string>::const_iterator di = deps.begin();
|
||||
for(std::vector<cmTarget*>::const_iterator di = deps.begin();
|
||||
di != deps.end(); ++di)
|
||||
{
|
||||
if (uniqueDeps.insert(*di).second)
|
||||
|
|
|
@ -5213,10 +5213,9 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmTarget::GetTransitivePropertyLinkLibraries(
|
||||
const char* config,
|
||||
void cmTarget::GetTransitivePropertyTargets(const char* config,
|
||||
cmTarget const* headTarget,
|
||||
std::vector<std::string> &libs) const
|
||||
std::vector<cmTarget*> &tgts) const
|
||||
{
|
||||
cmTarget::LinkInterface const* iface = this->GetLinkInterface(config,
|
||||
headTarget);
|
||||
|
@ -5228,7 +5227,15 @@ void cmTarget::GetTransitivePropertyLinkLibraries(
|
|||
|| this->GetPolicyStatusCMP0022() == cmPolicies::WARN
|
||||
|| this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
|
||||
{
|
||||
libs = iface->Libraries;
|
||||
for(std::vector<std::string>::const_iterator it = iface->Libraries.begin();
|
||||
it != iface->Libraries.end(); ++it)
|
||||
{
|
||||
if (cmTarget* tgt = headTarget->GetMakefile()
|
||||
->FindTargetToUse(it->c_str()))
|
||||
{
|
||||
tgts.push_back(tgt);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5246,12 +5253,23 @@ void cmTarget::GetTransitivePropertyLinkLibraries(
|
|||
cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
|
||||
linkIfaceProp, 0, 0);
|
||||
dagChecker.SetTransitivePropertiesOnly();
|
||||
std::vector<std::string> libs;
|
||||
cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate(
|
||||
this->Makefile,
|
||||
config,
|
||||
false,
|
||||
headTarget,
|
||||
this, &dagChecker), libs);
|
||||
|
||||
for(std::vector<std::string>::const_iterator it = libs.begin();
|
||||
it != libs.end(); ++it)
|
||||
{
|
||||
if (cmTarget* tgt = headTarget->GetMakefile()
|
||||
->FindTargetToUse(it->c_str()))
|
||||
{
|
||||
tgts.push_back(tgt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -264,9 +264,9 @@ public:
|
|||
if the target cannot be linked. */
|
||||
LinkInterface const* GetLinkInterface(const char* config,
|
||||
cmTarget const* headTarget) const;
|
||||
void GetTransitivePropertyLinkLibraries(const char* config,
|
||||
void GetTransitivePropertyTargets(const char* config,
|
||||
cmTarget const* headTarget,
|
||||
std::vector<std::string> &libs) const;
|
||||
std::vector<cmTarget*> &libs) const;
|
||||
|
||||
/** The link implementation specifies the direct library
|
||||
dependencies needed by the object files of the target. */
|
||||
|
|
Loading…
Reference in New Issue