Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmGeneratorExpression.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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 #include "cmStandardIncludes.h"
13
14 #include <stack>
15
16 #include <cmsys/RegularExpression.hxx>
17
18 class cmTarget;
19 class cmMakefile;
20 class cmListFileBacktrace;
21
22 /** \class cmGeneratorExpression
23  * \brief Evaluate generate-time query expression syntax.
24  *
25  * cmGeneratorExpression instances are used by build system generator
26  * implementations to evaluate the $<> generator expression syntax.
27  * Generator expressions are evaluated just before the generate step
28  * writes strings into the build system.  They have knowledge of the
29  * build configuration which is not available at configure time.
30  */
31 class cmGeneratorExpression
32 {
33 public:
34   /** Construct with an evaluation context and configuration.  */
35   cmGeneratorExpression(cmMakefile* mf, const char* config,
36                         cmListFileBacktrace const& backtrace,
37                         bool quiet = false);
38
39   /** Evaluate generator expressions in a string.  */
40   const char* Process(std::string const& input);
41   const char* Process(const char* input);
42
43   /** Get set of targets found during evaluations.  */
44   std::set<cmTarget*> const& GetTargets() const
45     { return this->Targets; }
46 private:
47   cmMakefile* Makefile;
48   const char* Config;
49   cmListFileBacktrace const& Backtrace;
50   bool Quiet;
51   std::vector<char> Data;
52   std::stack<size_t> Barriers;
53   cmsys::RegularExpression TargetInfo;
54   std::set<cmTarget*> Targets;
55   bool Evaluate();
56   bool Evaluate(const char* expr, std::string& result);
57   bool EvaluateTargetInfo(std::string& result);
58 };