summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2012-11-26 21:43:13 (GMT)
committerBrad King <brad.king@kitware.com>2012-11-27 14:12:39 (GMT)
commit07749e3705cfc0105399c4a7a8349ec9f83ba39c (patch)
tree204a97eccfbf03864d61459876ee301dbdb40010
parentee96dc76864b899684d62b51edd87d3083e80168 (diff)
downloadCMake-07749e3705cfc0105399c4a7a8349ec9f83ba39c.zip
CMake-07749e3705cfc0105399c4a7a8349ec9f83ba39c.tar.gz
CMake-07749e3705cfc0105399c4a7a8349ec9f83ba39c.tar.bz2
Genex: Ensure that $<0:...> has a parameter.
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx16
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadZero-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadZero.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake1
5 files changed, 30 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 23f641d..3c2f7c5 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -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();
}
diff --git a/Tests/RunCMake/GeneratorExpression/BadZero-result.txt b/Tests/RunCMake/GeneratorExpression/BadZero-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/BadZero-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt
new file mode 100644
index 0000000..ce04482
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt
@@ -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\)
diff --git a/Tests/RunCMake/GeneratorExpression/BadZero.cmake b/Tests/RunCMake/GeneratorExpression/BadZero.cmake
new file mode 100644
index 0000000..295ab0e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/BadZero.cmake
@@ -0,0 +1,4 @@
+
+add_custom_target(check ALL COMMAND check
+ $<0>
+ VERBATIM)
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
index 18a47ae..992ba79 100644
--- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
@@ -5,3 +5,4 @@ run_cmake(BadOR)
run_cmake(BadAND)
run_cmake(BadNOT)
run_cmake(BadStrEqual)
+run_cmake(BadZero)