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);
62 static void Split(const std::string &input,
63 std::vector<std::string> &output);
65 static std::string::size_type Find(const std::string &input);
67 static bool IsValidTargetName(const std::string &input);
69 static std::string StripEmptyListElements(const std::string &input);
71 cmGeneratorExpression(const cmGeneratorExpression &);
72 void operator=(const cmGeneratorExpression &);
74 cmListFileBacktrace const& Backtrace;
77 class cmCompiledGeneratorExpression
80 const char* Evaluate(cmMakefile* mf, const char* config,
82 cmTarget *headTarget = 0,
83 cmTarget *currentTarget = 0,
84 cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
85 const char* Evaluate(cmMakefile* mf, const char* config,
88 cmGeneratorExpressionDAGChecker *dagChecker) const;
90 /** Get set of targets found during evaluations. */
91 std::set<cmTarget*> const& GetTargets() const
92 { return this->DependTargets; }
94 std::set<cmStdString> const& GetSeenTargetProperties() const
95 { return this->SeenTargetProperties; }
97 std::set<cmTarget*> const& GetAllTargetsSeen() const
98 { return this->AllTargetsSeen; }
100 ~cmCompiledGeneratorExpression();
102 std::string GetInput() const
107 cmListFileBacktrace GetBacktrace() const
109 return this->Backtrace;
111 bool GetHadContextSensitiveCondition() const
113 return this->HadContextSensitiveCondition;
117 cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
120 friend class cmGeneratorExpression;
122 cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
123 void operator=(const cmCompiledGeneratorExpression &);
125 cmListFileBacktrace Backtrace;
126 std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
127 const std::string Input;
130 mutable std::set<cmTarget*> DependTargets;
131 mutable std::set<cmTarget*> AllTargetsSeen;
132 mutable std::set<cmStdString> SeenTargetProperties;
133 mutable std::string Output;
134 mutable bool HadContextSensitiveCondition;