ソースを参照

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

Stephen Kelly 13 年 前
コミット
07749e3705

+ 16 - 0
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();
     }
 

+ 1 - 0
Tests/RunCMake/GeneratorExpression/BadZero-result.txt

@@ -0,0 +1 @@
+1

+ 8 - 0
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\)

+ 4 - 0
Tests/RunCMake/GeneratorExpression/BadZero.cmake

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

+ 1 - 0
Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake

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