summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionEvaluator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-07-15 15:50:32 (GMT)
committerBrad King <brad.king@kitware.com>2014-07-16 17:31:30 (GMT)
commit8cb9105431bcc4bd206d92b7cd53cebdb1a783bd (patch)
tree288385be065ddd78961e2a0059534b4ec59db63c /Source/cmGeneratorExpressionEvaluator.cxx
parent0a8fbac19a1d12adaa10873cc8fdb3dff164c981 (diff)
downloadCMake-8cb9105431bcc4bd206d92b7cd53cebdb1a783bd.zip
CMake-8cb9105431bcc4bd206d92b7cd53cebdb1a783bd.tar.gz
CMake-8cb9105431bcc4bd206d92b7cd53cebdb1a783bd.tar.bz2
Genex: Simplify TARGET_PROPERTY transitive lookup
In cmGeneratorExpressionEvaluator, make getLinkedTargetsContent a template so it can traverse over either the Libraries in a cmTarget LinkImplementationLibraries or a cmTarget LinkInterfaceLibraries. This also avoids creating a separate vector<cmTarget*>.
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx96
1 files changed, 31 insertions, 65 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 19b3e16..d08c3c9 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -799,70 +799,49 @@ static const char* targetPropertyTransitiveWhitelist[] = {
#undef TRANSITIVE_PROPERTY_NAME
+template <typename T>
std::string
getLinkedTargetsContent(
- std::vector<cmTarget const*> &targets,
+ std::vector<T> const &libraries,
cmTarget const* target,
cmTarget const* headTarget,
cmGeneratorExpressionContext *context,
cmGeneratorExpressionDAGChecker *dagChecker,
const std::string &interfacePropertyName)
{
- cmGeneratorExpression ge(&context->Backtrace);
-
+ std::string linkedTargetsContent;
std::string sep;
std::string depString;
- for (std::vector<cmTarget const*>::const_iterator
- it = targets.begin();
- it != targets.end(); ++it)
+ for (typename std::vector<T>::const_iterator it = libraries.begin();
+ it != libraries.end(); ++it)
{
- 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;
+ // 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.
+ if (it->Target && it->Target != target)
+ {
+ depString +=
+ sep + "$<TARGET_PROPERTY:" +
+ it->Target->GetName() + "," + interfacePropertyName + ">";
+ sep = ";";
}
- depString +=
- sep + "$<TARGET_PROPERTY:" +
- (*it)->GetName() + "," + interfacePropertyName + ">";
- sep = ";";
}
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
- std::string linkedTargetsContent = cge->Evaluate(target->GetMakefile(),
- context->Config,
- context->Quiet,
- headTarget,
- target,
- dagChecker);
- if (cge->GetHadContextSensitiveCondition())
- {
- context->HadContextSensitiveCondition = true;
- }
- return linkedTargetsContent;
-}
-
-std::string
-getLinkedTargetsContent(
- std::vector<cmLinkImplItem> const &libraries,
- cmTarget const* target,
- cmTarget const* headTarget,
- cmGeneratorExpressionContext *context,
- cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string &interfacePropertyName)
-{
- std::vector<cmTarget const*> tgts;
- for (std::vector<cmLinkImplItem>::const_iterator
- it = libraries.begin();
- it != libraries.end(); ++it)
+ if(!depString.empty())
{
- if (it->Target)
- {
- tgts.push_back(it->Target);
+ cmGeneratorExpression ge(&context->Backtrace);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
+ linkedTargetsContent = cge->Evaluate(target->GetMakefile(),
+ context->Config,
+ context->Quiet,
+ headTarget,
+ target,
+ dagChecker);
+ if (cge->GetHadContextSensitiveCondition())
+ {
+ context->HadContextSensitiveCondition = true;
}
}
- return getLinkedTargetsContent(tgts, target, headTarget, context,
- dagChecker, interfacePropertyName);
+ return linkedTargetsContent;
}
//----------------------------------------------------------------------------
@@ -1098,27 +1077,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (std::find_if(transBegin, transEnd,
cmStrCmp(propertyName)) != transEnd)
{
- std::vector<cmTarget const*> tgts;
if(cmTarget::LinkInterfaceLibraries const* iface =
target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
{
- for(std::vector<cmLinkItem>::const_iterator
- it = iface->Libraries.begin();
- it != iface->Libraries.end(); ++it)
- {
- if (it->Target)
- {
- tgts.push_back(it->Target);
- }
- }
- }
- if (!tgts.empty())
- {
linkedTargetsContent =
- getLinkedTargetsContent(tgts, target,
- headTarget,
- context, &dagChecker,
- interfacePropertyName);
+ getLinkedTargetsContent(iface->Libraries, target,
+ headTarget,
+ context, &dagChecker,
+ interfacePropertyName);
}
}
else if (std::find_if(transBegin, transEnd,