Browse Source

Allow generator expressions to require literals.

Stephen Kelly 13 years ago
parent
commit
77475fe61d
1 changed files with 17 additions and 0 deletions
  1. 17 0
      Source/cmGeneratorExpressionEvaluator.cxx

+ 17 - 0
Source/cmGeneratorExpressionEvaluator.cxx

@@ -47,6 +47,8 @@ struct cmGeneratorExpressionNode
 
   virtual bool GeneratesContent() const { return true; }
 
+  virtual bool RequiresLiteralInput() const { return false; }
+
   virtual bool AcceptsSingleArbitraryContentParameter() const
     { return false; }
 
@@ -692,6 +694,15 @@ std::string GeneratorExpressionContent::Evaluate(
                                                                 = 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)
           {
@@ -699,6 +710,12 @@ std::string GeneratorExpressionContent::Evaluate(
           }
         }
       }
+    if (node->RequiresLiteralInput())
+      {
+      std::vector<std::string> parameters;
+      parameters.push_back(result);
+      return node->Evaluate(parameters, context, this, dagChecker);
+      }
     return result;
     }