Genex: Ensure that $<0:...> has a parameter.

This commit is contained in:
Stephen Kelly 2012-11-26 22:43:13 +01:00 committed by Brad King
parent ee96dc7686
commit 07749e3705
5 changed files with 30 additions and 0 deletions

View File

@ -66,6 +66,8 @@ static const struct ZeroNode : public cmGeneratorExpressionNode
virtual bool GeneratesContent() const { return false; }
virtual bool AcceptsSingleArbitraryContentParameter() const { return true; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
@ -642,6 +644,20 @@ std::string GeneratorExpressionContent::Evaluate(
if (!node->GeneratesContent())
{
if (node->AcceptsSingleArbitraryContentParameter())
{
if (this->ParamChildren.empty())
{
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires a parameter.");
}
}
else
{
std::vector<std::string> parameters;
this->EvaluateParameters(node, identifier, context, dagChecker,
parameters);
}
return std::string();
}

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,8 @@
CMake Error at BadZero.cmake:2 \(add_custom_target\):
Error evaluating generator expression:
\$<0>
\$<0> expression requires a parameter.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,4 @@
add_custom_target(check ALL COMMAND check
$<0>
VERBATIM)

View File

@ -5,3 +5,4 @@ run_cmake(BadOR)
run_cmake(BadAND)
run_cmake(BadNOT)
run_cmake(BadStrEqual)
run_cmake(BadZero)