1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2012 Stephen Kelly <steveire@gmail.com>
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #ifndef cmGeneratorExpressionEvaluator_h
13 #define cmGeneratorExpressionEvaluator_h
18 #include "cmListFileCache.h"
22 //----------------------------------------------------------------------------
23 struct cmGeneratorExpressionContext
25 cmListFileBacktrace Backtrace;
26 std::set<cmTarget*> DependTargets;
27 std::set<cmTarget*> AllTargets;
28 std::set<cmStdString> SeenTargetProperties;
31 cmTarget *HeadTarget; // The target whose property is being evaluated.
32 cmTarget *CurrentTarget; // The dependent of HeadTarget which appears
33 // directly or indirectly in the property.
36 bool HadContextSensitiveCondition;
39 struct cmGeneratorExpressionDAGChecker;
40 struct cmGeneratorExpressionNode;
42 //----------------------------------------------------------------------------
43 struct cmGeneratorExpressionEvaluator
45 cmGeneratorExpressionEvaluator() {}
46 virtual ~cmGeneratorExpressionEvaluator() {}
54 virtual Type GetType() const = 0;
56 virtual std::string Evaluate(cmGeneratorExpressionContext *context,
57 cmGeneratorExpressionDAGChecker *) const = 0;
60 cmGeneratorExpressionEvaluator(const cmGeneratorExpressionEvaluator &);
61 void operator=(const cmGeneratorExpressionEvaluator &);
64 struct TextContent : public cmGeneratorExpressionEvaluator
66 TextContent(const char *start, unsigned int length)
67 : Content(start), Length(length)
72 std::string Evaluate(cmGeneratorExpressionContext *,
73 cmGeneratorExpressionDAGChecker *) const
75 return std::string(this->Content, this->Length);
80 return cmGeneratorExpressionEvaluator::Text;
83 void Extend(unsigned int length)
85 this->Length += length;
88 unsigned int GetLength()
98 //----------------------------------------------------------------------------
99 struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
101 GeneratorExpressionContent(const char *startContent, unsigned int length);
102 void SetIdentifier(std::vector<cmGeneratorExpressionEvaluator*> identifier)
104 this->IdentifierChildren = identifier;
108 std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters)
110 this->ParamChildren = parameters;
115 return cmGeneratorExpressionEvaluator::Generator;
118 std::string Evaluate(cmGeneratorExpressionContext *context,
119 cmGeneratorExpressionDAGChecker *) const;
121 std::string GetOriginalExpression() const;
123 ~GeneratorExpressionContent();
126 std::string EvaluateParameters(const cmGeneratorExpressionNode *node,
127 const std::string &identifier,
128 cmGeneratorExpressionContext *context,
129 cmGeneratorExpressionDAGChecker *dagChecker,
130 std::vector<std::string> ¶meters) const;
132 std::string ProcessArbitraryContent(
133 const cmGeneratorExpressionNode *node,
134 const std::string &identifier,
135 cmGeneratorExpressionContext *context,
136 cmGeneratorExpressionDAGChecker *dagChecker,
137 std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
141 std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren;
142 std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren;
143 const char *StartContent;
144 unsigned int ContentLength;