1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
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 ============================================================================*/
13 #ifndef cmGeneratorExpression_h
14 #define cmGeneratorExpression_h
16 #include "cmStandardIncludes.h"
17 #include "cmListFileCache.h"
21 #include <cmsys/RegularExpression.hxx>
22 #include <cmsys/auto_ptr.hxx>
26 class cmListFileBacktrace;
28 struct cmGeneratorExpressionEvaluator;
29 struct cmGeneratorExpressionDAGChecker;
31 class cmCompiledGeneratorExpression;
33 /** \class cmGeneratorExpression
34 * \brief Evaluate generate-time query expression syntax.
36 * cmGeneratorExpression instances are used by build system generator
37 * implementations to evaluate the $<> generator expression syntax.
38 * Generator expressions are evaluated just before the generate step
39 * writes strings into the build system. They have knowledge of the
40 * build configuration which is not available at configure time.
42 class cmGeneratorExpression
46 cmGeneratorExpression(cmListFileBacktrace const& backtrace);
47 ~cmGeneratorExpression();
49 cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(
50 std::string const& input);
51 cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
53 enum PreprocessContext {
54 StripAllGeneratorExpressions,
59 static std::string Preprocess(const std::string &input,
60 PreprocessContext context,
61 bool resolveRelative = false);
63 static void Split(const std::string &input,
64 std::vector<std::string> &output);
66 static std::string::size_type Find(const std::string &input);
68 static bool IsValidTargetName(const std::string &input);
70 static std::string StripEmptyListElements(const std::string &input);
72 cmGeneratorExpression(const cmGeneratorExpression &);
73 void operator=(const cmGeneratorExpression &);
75 cmListFileBacktrace const& Backtrace;
78 class cmCompiledGeneratorExpression
81 const char* Evaluate(cmMakefile* mf, const char* config,
83 cmTarget *headTarget = 0,
84 cmTarget *currentTarget = 0,
85 cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
86 const char* Evaluate(cmMakefile* mf, const char* config,
89 cmGeneratorExpressionDAGChecker *dagChecker) const;
91 /** Get set of targets found during evaluations. */
92 std::set<cmTarget*> const& GetTargets() const
93 { return this->DependTargets; }
95 std::set<cmStdString> const& GetSeenTargetProperties() const
96 { return this->SeenTargetProperties; }
98 std::set<cmTarget*> const& GetAllTargetsSeen() const
99 { return this->AllTargetsSeen; }
101 ~cmCompiledGeneratorExpression();
103 std::string GetInput() const
108 cmListFileBacktrace GetBacktrace() const
110 return this->Backtrace;
112 bool GetHadContextSensitiveCondition() const
114 return this->HadContextSensitiveCondition;
118 cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
121 friend class cmGeneratorExpression;
123 cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
124 void operator=(const cmCompiledGeneratorExpression &);
126 cmListFileBacktrace Backtrace;
127 std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
128 const std::string Input;
131 mutable std::set<cmTarget*> DependTargets;
132 mutable std::set<cmTarget*> AllTargetsSeen;
133 mutable std::set<cmStdString> SeenTargetProperties;
134 mutable std::string Output;
135 mutable bool HadContextSensitiveCondition;