summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionEvaluator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx586
1 files changed, 500 insertions, 86 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index a01a0f890..8b3135412 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -45,13 +45,18 @@ void reportError(cmGeneratorExpressionContext *context,
//----------------------------------------------------------------------------
struct cmGeneratorExpressionNode
{
+ enum {
+ DynamicParameters = 0,
+ OneOrMoreParameters = -1,
+ ZeroOrMoreParameters = -2
+ };
virtual ~cmGeneratorExpressionNode() {}
virtual bool GeneratesContent() const { return true; }
virtual bool RequiresLiteralInput() const { return false; }
- virtual bool AcceptsSingleArbitraryContentParameter() const
+ virtual bool AcceptsArbitraryContentParameter() const
{ return false; }
virtual int NumExpectedParameters() const { return 1; }
@@ -70,7 +75,7 @@ static const struct ZeroNode : public cmGeneratorExpressionNode
virtual bool GeneratesContent() const { return false; }
- virtual bool AcceptsSingleArbitraryContentParameter() const { return true; }
+ virtual bool AcceptsArbitraryContentParameter() const { return true; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *,
@@ -87,7 +92,7 @@ static const struct OneNode : public cmGeneratorExpressionNode
{
OneNode() {}
- virtual bool AcceptsSingleArbitraryContentParameter() const { return true; }
+ virtual bool AcceptsArbitraryContentParameter() const { return true; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *,
@@ -110,8 +115,7 @@ static const struct ZeroNode installInterfaceNode;
static const struct OP ## Node : public cmGeneratorExpressionNode \
{ \
OP ## Node () {} \
-/* We let -1 carry the meaning 'at least one' */ \
- virtual int NumExpectedParameters() const { return -1; } \
+ virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
\
std::string Evaluate(const std::vector<std::string> &parameters, \
cmGeneratorExpressionContext *context, \
@@ -243,6 +247,269 @@ static const struct SemicolonNode : public cmGeneratorExpressionNode
} semicolonNode;
//----------------------------------------------------------------------------
+struct CompilerIdNode : public cmGeneratorExpressionNode
+{
+ CompilerIdNode() {}
+
+ virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
+
+ std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *,
+ const std::string &lang) const
+ {
+ const char *compilerId = context->Makefile ?
+ context->Makefile->GetSafeDefinition((
+ "CMAKE_" + lang + "_COMPILER_ID").c_str()) : "";
+ if (parameters.size() == 0)
+ {
+ return compilerId ? compilerId : "";
+ }
+ cmsys::RegularExpression compilerIdValidator;
+ compilerIdValidator.compile("^[A-Za-z0-9_]*$");
+ if (!compilerIdValidator.find(parameters.begin()->c_str()))
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "Expression syntax not recognized.");
+ return std::string();
+ }
+ if (!compilerId)
+ {
+ return parameters.front().empty() ? "1" : "0";
+ }
+
+ if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
+ {
+ return "1";
+ }
+ return "0";
+ }
+};
+
+//----------------------------------------------------------------------------
+static const struct CCompilerIdNode : public CompilerIdNode
+{
+ CCompilerIdNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if (parameters.size() != 0 && parameters.size() != 1)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<C_COMPILER_ID> expression requires one or two parameters");
+ return std::string();
+ }
+ if (!context->HeadTarget)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<C_COMPILER_ID> may only be used with targets. It may not "
+ "be used with add_custom_command.");
+ }
+ return this->EvaluateWithLanguage(parameters, context, content,
+ dagChecker, "C");
+ }
+} cCompilerIdNode;
+
+//----------------------------------------------------------------------------
+static const struct CXXCompilerIdNode : public CompilerIdNode
+{
+ CXXCompilerIdNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if (parameters.size() != 0 && parameters.size() != 1)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<CXX_COMPILER_ID> expression requires one or two parameters");
+ return std::string();
+ }
+ if (!context->HeadTarget)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<CXX_COMPILER_ID> may only be used with targets. It may not "
+ "be used with add_custom_command.");
+ }
+ return this->EvaluateWithLanguage(parameters, context, content,
+ dagChecker, "CXX");
+ }
+} cxxCompilerIdNode;
+
+//----------------------------------------------------------------------------
+struct CompilerVersionNode : public cmGeneratorExpressionNode
+{
+ CompilerVersionNode() {}
+
+ virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
+
+ std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *,
+ const std::string &lang) const
+ {
+ const char *compilerVersion = context->Makefile ?
+ context->Makefile->GetSafeDefinition((
+ "CMAKE_" + lang + "_COMPILER_VERSION").c_str()) : "";
+ if (parameters.size() == 0)
+ {
+ return compilerVersion ? compilerVersion : "";
+ }
+
+ cmsys::RegularExpression compilerIdValidator;
+ compilerIdValidator.compile("^[0-9\\.]*$");
+ if (!compilerIdValidator.find(parameters.begin()->c_str()))
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "Expression syntax not recognized.");
+ return std::string();
+ }
+ if (!compilerVersion)
+ {
+ return parameters.front().empty() ? "1" : "0";
+ }
+
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
+ parameters.begin()->c_str(),
+ compilerVersion) ? "1" : "0";
+ }
+};
+
+//----------------------------------------------------------------------------
+static const struct CCompilerVersionNode : public CompilerVersionNode
+{
+ CCompilerVersionNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if (parameters.size() != 0 && parameters.size() != 1)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<C_COMPILER_VERSION> expression requires one or two parameters");
+ return std::string();
+ }
+ if (!context->HeadTarget)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<C_COMPILER_VERSION> may only be used with targets. It may not "
+ "be used with add_custom_command.");
+ }
+ return this->EvaluateWithLanguage(parameters, context, content,
+ dagChecker, "C");
+ }
+} cCompilerVersionNode;
+
+//----------------------------------------------------------------------------
+static const struct CxxCompilerVersionNode : public CompilerVersionNode
+{
+ CxxCompilerVersionNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if (parameters.size() != 0 && parameters.size() != 1)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<CXX_COMPILER_VERSION> expression requires one or two "
+ "parameters");
+ return std::string();
+ }
+ if (!context->HeadTarget)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<CXX_COMPILER_VERSION> may only be used with targets. It may "
+ "not be used with add_custom_command.");
+ }
+ return this->EvaluateWithLanguage(parameters, context, content,
+ dagChecker, "CXX");
+ }
+} cxxCompilerVersionNode;
+
+
+//----------------------------------------------------------------------------
+static const struct VersionGreaterNode : public cmGeneratorExpressionNode
+{
+ VersionGreaterNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
+ parameters.front().c_str(),
+ parameters[1].c_str()) ? "1" : "0";
+ }
+} versionGreaterNode;
+
+//----------------------------------------------------------------------------
+static const struct VersionLessNode : public cmGeneratorExpressionNode
+{
+ VersionLessNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
+ parameters.front().c_str(),
+ parameters[1].c_str()) ? "1" : "0";
+ }
+} versionLessNode;
+
+//----------------------------------------------------------------------------
+static const struct VersionEqualNode : public cmGeneratorExpressionNode
+{
+ VersionEqualNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
+ parameters.front().c_str(),
+ parameters[1].c_str()) ? "1" : "0";
+ }
+} versionEqualNode;
+
+//----------------------------------------------------------------------------
+static const struct LinkOnlyNode : public cmGeneratorExpressionNode
+{
+ LinkOnlyNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if(!dagChecker->GetTransitivePropertiesOnly())
+ {
+ return parameters.front();
+ }
+ return "";
+ }
+} linkOnlyNode;
+
+//----------------------------------------------------------------------------
static const struct ConfigurationNode : public cmGeneratorExpressionNode
{
ConfigurationNode() {}
@@ -297,20 +564,67 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
const char* loc = 0;
const char* imp = 0;
std::string suffix;
- return context->CurrentTarget->GetMappedConfig(context->Config,
+ if (context->CurrentTarget->GetMappedConfig(context->Config,
&loc,
&imp,
- suffix) ? "1" : "0";
+ suffix))
+ {
+ // This imported target has an appropriate location
+ // for this (possibly mapped) config.
+ // Check if there is a proper config mapping for the tested config.
+ std::vector<std::string> mappedConfigs;
+ std::string mapProp = "MAP_IMPORTED_CONFIG_";
+ mapProp += cmSystemTools::UpperCase(context->Config);
+ if(const char* mapValue =
+ context->CurrentTarget->GetProperty(mapProp.c_str()))
+ {
+ cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
+ mappedConfigs);
+ return std::find(mappedConfigs.begin(), mappedConfigs.end(),
+ cmSystemTools::UpperCase(parameters.front()))
+ != mappedConfigs.end() ? "1" : "0";
+ }
+ }
}
return "0";
}
} configurationTestNode;
+static const struct JoinNode : public cmGeneratorExpressionNode
+{
+ JoinNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ virtual bool AcceptsArbitraryContentParameter() const { return true; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ std::string result;
+
+ std::vector<std::string> list;
+ cmSystemTools::ExpandListArgument(parameters.front(), list);
+ std::string sep;
+ for(std::vector<std::string>::const_iterator li = list.begin();
+ li != list.end(); ++li)
+ {
+ result += sep + *li;
+ sep = parameters[1];
+ }
+ return result;
+ }
+} joinNode;
+
+#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
+ , #PROPERTY
//----------------------------------------------------------------------------
static const char* targetPropertyTransitiveWhitelist[] = {
- "INTERFACE_INCLUDE_DIRECTORIES"
- , "INTERFACE_COMPILE_DEFINITIONS"
+ 0
+ CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
};
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
@@ -373,7 +687,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
TargetPropertyNode() {}
// This node handles errors on parameter count itself.
- virtual int NumExpectedParameters() const { return -1; }
+ virtual int NumExpectedParameters() const { return OneOrMoreParameters; }
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context,
@@ -434,6 +748,18 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"Target name not supported.");
return std::string();
}
+ if(propertyName == "ALIASED_TARGET")
+ {
+ if(context->Makefile->IsAlias(targetName.c_str()))
+ {
+ if(cmTarget* tgt =
+ context->Makefile->FindTargetToUse(targetName.c_str()))
+ {
+ return tgt->GetName();
+ }
+ }
+ return "";
+ }
target = context->Makefile->FindTargetToUse(
targetName.c_str());
@@ -475,6 +801,20 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
assert(target);
+ if (propertyName == "LINKER_LANGUAGE")
+ {
+ if (target->LinkLanguagePropagatesToDependents() &&
+ dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries())
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "LINKER_LANGUAGE target property can not be used while evaluating "
+ "link libraries for a static library");
+ return std::string();
+ }
+ const char *lang = target->GetLinkerLanguage(context->Config);
+ return lang ? lang : "";
+ }
+
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
target->GetName(),
propertyName,
@@ -490,7 +830,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
// No error. We just skip cyclic references.
return std::string();
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
- for (size_t i = 0;
+ for (size_t i = 1;
i < (sizeof(targetPropertyTransitiveWhitelist) /
sizeof(*targetPropertyTransitiveWhitelist));
++i)
@@ -518,8 +858,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
}
else
{
- assert(dagCheckerParent->EvaluatingIncludeDirectories()
- || dagCheckerParent->EvaluatingCompileDefinitions());
+#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) \
+ dagCheckerParent->METHOD () ||
+
+ assert(
+ CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
+ ASSERT_TRANSITIVE_PROPERTY_METHOD)
+ false);
}
}
@@ -532,29 +877,39 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
interfacePropertyName = "INTERFACE_INCLUDE_DIRECTORIES";
}
+ else if (propertyName == "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")
+ {
+ interfacePropertyName = "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES";
+ }
else if (propertyName == "INTERFACE_COMPILE_DEFINITIONS"
|| propertyName == "COMPILE_DEFINITIONS"
|| strncmp(propertyName.c_str(), "COMPILE_DEFINITIONS_", 20) == 0)
{
interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
}
+ else if (propertyName == "INTERFACE_COMPILE_OPTIONS"
+ || propertyName == "COMPILE_OPTIONS")
+ {
+ interfacePropertyName = "INTERFACE_COMPILE_OPTIONS";
+ }
cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
- const char **transBegin = targetPropertyTransitiveWhitelist;
+ const char **transBegin = targetPropertyTransitiveWhitelist + 1;
const char **transEnd = targetPropertyTransitiveWhitelist
+ (sizeof(targetPropertyTransitiveWhitelist) /
sizeof(*targetPropertyTransitiveWhitelist));
if (std::find_if(transBegin, transEnd,
TransitiveWhitelistCompare(propertyName)) != transEnd)
{
- const cmTarget::LinkInterface *iface = target->GetLinkInterface(
- context->Config,
- headTarget);
- if(iface)
+
+ std::vector<std::string> libs;
+ target->GetTransitivePropertyLinkLibraries(context->Config,
+ headTarget, libs);
+ if (!libs.empty())
{
linkedTargetsContent =
- getLinkedTargetsContent(iface->Libraries, target,
+ getLinkedTargetsContent(libs, target,
headTarget,
context, &dagChecker,
interfacePropertyName);
@@ -607,7 +962,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return linkedTargetsContent;
}
- for (size_t i = 0;
+ for (size_t i = 1;
i < (sizeof(targetPropertyTransitiveWhitelist) /
sizeof(*targetPropertyTransitiveWhitelist));
++i)
@@ -645,7 +1000,7 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
virtual bool GeneratesContent() const { return true; }
- virtual bool AcceptsSingleArbitraryContentParameter() const { return true; }
+ virtual bool AcceptsArbitraryContentParameter() const { return true; }
virtual bool RequiresLiteralInput() const { return true; }
std::string Evaluate(const std::vector<std::string> &parameters,
@@ -662,10 +1017,13 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
//----------------------------------------------------------------------------
static const char* targetPolicyWhitelist[] = {
- "CMP0003"
- , "CMP0004"
- , "CMP0008"
- , "CMP0020"
+ 0
+#define TARGET_POLICY_STRING(POLICY) \
+ , #POLICY
+
+ CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
+
+#undef TARGET_POLICY_STRING
};
cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy)
@@ -676,10 +1034,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy)
return tgt->GetPolicyStatus ## POLICY (); \
} \
- RETURN_POLICY(CMP0003)
- RETURN_POLICY(CMP0004)
- RETURN_POLICY(CMP0008)
- RETURN_POLICY(CMP0020)
+ CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
#undef RETURN_POLICY
@@ -695,10 +1050,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id)
return cmPolicies:: POLICY_ID; \
} \
- RETURN_POLICY_ID(CMP0003)
- RETURN_POLICY_ID(CMP0004)
- RETURN_POLICY_ID(CMP0008)
- RETURN_POLICY_ID(CMP0020)
+ CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID)
#undef RETURN_POLICY_ID
@@ -728,7 +1080,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
context->HadContextSensitiveCondition = true;
- for (size_t i = 0;
+ for (size_t i = 1;
i < (sizeof(targetPolicyWhitelist) /
sizeof(*targetPolicyWhitelist));
++i)
@@ -754,8 +1106,17 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
}
reportError(context, content->GetOriginalExpression(),
"$<TARGET_POLICY:prop> may only be used with a limited number of "
- "policies. Currently it may be used with policies CMP0003, CMP0004, "
- "CMP0008 and CMP0020."
+ "policies. Currently it may be used with the following policies:\n"
+
+#define STRINGIFY_HELPER(X) #X
+#define STRINGIFY(X) STRINGIFY_HELPER(X)
+
+#define TARGET_POLICY_LIST_ITEM(POLICY) \
+ " * " STRINGIFY(POLICY) "\n"
+
+ CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM)
+
+#undef TARGET_POLICY_LIST_ITEM
);
return std::string();
}
@@ -898,7 +1259,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
std::string Evaluate(const std::vector<std::string> &parameters,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content,
- cmGeneratorExpressionDAGChecker *) const
+ cmGeneratorExpressionDAGChecker *dagChecker) const
{
// Lookup the referenced target.
std::string name = *parameters.begin();
@@ -916,13 +1277,20 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
"No target \"" + name + "\"");
return std::string();
}
- if(target->GetType() >= cmTarget::UTILITY &&
+ if(target->GetType() >= cmTarget::OBJECT_LIBRARY &&
target->GetType() != cmTarget::UNKNOWN_LIBRARY)
{
::reportError(context, content->GetOriginalExpression(),
"Target \"" + name + "\" is not an executable or library.");
return std::string();
}
+ if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str()))
+ {
+ ::reportError(context, content->GetOriginalExpression(),
+ "Expressions which require the linker language may not "
+ "be used while evaluating link libraries");
+ return std::string();
+ }
context->DependTargets.insert(target);
context->AllTargets.insert(target);
@@ -974,6 +1342,20 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &orNode;
else if (identifier == "NOT")
return &notNode;
+ else if (identifier == "C_COMPILER_ID")
+ return &cCompilerIdNode;
+ else if (identifier == "CXX_COMPILER_ID")
+ return &cxxCompilerIdNode;
+ else if (identifier == "VERSION_GREATER")
+ return &versionGreaterNode;
+ else if (identifier == "VERSION_LESS")
+ return &versionLessNode;
+ else if (identifier == "VERSION_EQUAL")
+ return &versionEqualNode;
+ else if (identifier == "C_COMPILER_VERSION")
+ return &cCompilerVersionNode;
+ else if (identifier == "CXX_COMPILER_VERSION")
+ return &cxxCompilerVersionNode;
else if (identifier == "CONFIGURATION")
return &configurationNode;
else if (identifier == "CONFIG")
@@ -1018,6 +1400,10 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &installInterfaceNode;
else if (identifier == "INSTALL_PREFIX")
return &installPrefixNode;
+ else if (identifier == "JOIN")
+ return &joinNode;
+ else if (identifier == "LINK_ONLY")
+ return &linkOnlyNode;
return 0;
}
@@ -1038,6 +1424,57 @@ std::string GeneratorExpressionContent::GetOriginalExpression() const
}
//----------------------------------------------------------------------------
+std::string GeneratorExpressionContent::ProcessArbitraryContent(
+ const cmGeneratorExpressionNode *node,
+ const std::string &identifier,
+ cmGeneratorExpressionContext *context,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
+ pit) const
+{
+ std::string result;
+
+ const
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
+ pend = this->ParamChildren.end();
+ for ( ; pit != pend; ++pit)
+ {
+ std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
+ = pit->begin();
+ const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
+ = pit->end();
+ for ( ; it != end; ++it)
+ {
+ if (node->RequiresLiteralInput())
+ {
+ if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
+ {
+ reportError(context, this->GetOriginalExpression(),
+ "$<" + identifier + "> expression requires literal input.");
+ return std::string();
+ }
+ }
+ result += (*it)->Evaluate(context, dagChecker);
+ if (context->HadError)
+ {
+ return std::string();
+ }
+ }
+ if ((pit + 1) != pend)
+ {
+ result += ",";
+ }
+ }
+ if (node->RequiresLiteralInput())
+ {
+ std::vector<std::string> parameters;
+ parameters.push_back(result);
+ return node->Evaluate(parameters, context, this, dagChecker);
+ }
+ return result;
+}
+
+//----------------------------------------------------------------------------
std::string GeneratorExpressionContent::Evaluate(
cmGeneratorExpressionContext *context,
cmGeneratorExpressionDAGChecker *dagChecker) const
@@ -1069,7 +1506,8 @@ std::string GeneratorExpressionContent::Evaluate(
if (!node->GeneratesContent())
{
- if (node->AcceptsSingleArbitraryContentParameter())
+ if (node->NumExpectedParameters() == 1
+ && node->AcceptsArbitraryContentParameter())
{
if (this->ParamChildren.empty())
{
@@ -1086,50 +1524,12 @@ std::string GeneratorExpressionContent::Evaluate(
return std::string();
}
- if (node->AcceptsSingleArbitraryContentParameter())
+ if (node->NumExpectedParameters() == 1
+ && node->AcceptsArbitraryContentParameter())
{
- std::string result;
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
- pit = this->ParamChildren.begin();
- const
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
- pend = this->ParamChildren.end();
- for ( ; pit != pend; ++pit)
- {
- if (!result.empty())
- {
- result += ",";
- }
-
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
- = pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
- = pit->end();
- for ( ; it != end; ++it)
- {
- if (node->RequiresLiteralInput())
- {
- if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
- {
- reportError(context, this->GetOriginalExpression(),
- "$<" + identifier + "> expression requires literal input.");
- return std::string();
- }
- }
- result += (*it)->Evaluate(context, dagChecker);
- if (context->HadError)
- {
- return std::string();
- }
- }
- }
- if (node->RequiresLiteralInput())
- {
- std::vector<std::string> parameters;
- parameters.push_back(result);
- return node->Evaluate(parameters, context, this, dagChecker);
- }
- return result;
+ return this->ProcessArbitraryContent(node, identifier, context,
+ dagChecker,
+ this->ParamChildren.begin());
}
std::vector<std::string> parameters;
@@ -1150,12 +1550,15 @@ std::string GeneratorExpressionContent::EvaluateParameters(
cmGeneratorExpressionDAGChecker *dagChecker,
std::vector<std::string> &parameters) const
{
+ const int numExpected = node->NumExpectedParameters();
{
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pit = this->ParamChildren.begin();
const
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
pend = this->ParamChildren.end();
+ const bool acceptsArbitraryContent
+ = node->AcceptsArbitraryContentParameter();
for ( ; pit != pend; ++pit)
{
std::string parameter;
@@ -1172,11 +1575,22 @@ std::string GeneratorExpressionContent::EvaluateParameters(
}
}
parameters.push_back(parameter);
+ if (acceptsArbitraryContent
+ && parameters.size() == (unsigned int)numExpected - 1)
+ {
+ assert(pit != pend);
+ std::string lastParam = this->ProcessArbitraryContent(node, identifier,
+ context,
+ dagChecker,
+ pit + 1);
+ parameters.push_back(lastParam);
+ return std::string();
+ }
}
}
- int numExpected = node->NumExpectedParameters();
- if ((numExpected != -1 && (unsigned int)numExpected != parameters.size()))
+ if ((numExpected > cmGeneratorExpressionNode::DynamicParameters
+ && (unsigned int)numExpected != parameters.size()))
{
if (numExpected == 0)
{
@@ -1201,7 +1615,8 @@ std::string GeneratorExpressionContent::EvaluateParameters(
return std::string();
}
- if (numExpected == -1 && parameters.empty())
+ if (numExpected == cmGeneratorExpressionNode::OneOrMoreParameters
+ && parameters.empty())
{
reportError(context, this->GetOriginalExpression(), "$<" + identifier
+ "> expression requires at least one parameter.");
@@ -1228,7 +1643,6 @@ GeneratorExpressionContent::~GeneratorExpressionContent()
deleteAll(this->IdentifierChildren);
typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
- typedef std::vector<cmGeneratorExpressionToken> TokenVector;
std::vector<EvaluatorVector>::const_iterator pit =
this->ParamChildren.begin();
const std::vector<EvaluatorVector>::const_iterator pend =