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