CMake/Source/cmGeneratorExpression.h
Stephen Kelly d8a59ea4b3 Port cmGeneratorExpression to cmTarget from cmGeneratorTarget.
Following from the discussion here:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/3615/focus=5170
 (Re: Generator expressisons in target properties, 26 Oct 12:10)

we can't split cmTarget API for linking into cmGeneratorTarget. In
the future we will probably also need to move the include and compile
definitions API back to cmTarget so that it can be used by export().
2012-11-21 00:11:54 +01:00

99 lines
3.0 KiB
C++

/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmGeneratorExpression_h
#define cmGeneratorExpression_h
#include "cmStandardIncludes.h"
#include <stack>
#include <cmsys/RegularExpression.hxx>
class cmTarget;
class cmMakefile;
class cmListFileBacktrace;
struct cmGeneratorExpressionEvaluator;
struct cmGeneratorExpressionDAGChecker;
class cmCompiledGeneratorExpression;
/** \class cmGeneratorExpression
* \brief Evaluate generate-time query expression syntax.
*
* cmGeneratorExpression instances are used by build system generator
* implementations to evaluate the $<> generator expression syntax.
* Generator expressions are evaluated just before the generate step
* writes strings into the build system. They have knowledge of the
* build configuration which is not available at configure time.
*/
class cmGeneratorExpression
{
public:
/** Construct. */
cmGeneratorExpression(cmListFileBacktrace const& backtrace);
~cmGeneratorExpression();
const cmCompiledGeneratorExpression& Parse(std::string const& input);
const cmCompiledGeneratorExpression& Parse(const char* input);
enum PreprocessContext {
StripAllGeneratorExpressions
};
static std::string Preprocess(const std::string &input,
PreprocessContext context);
private:
cmGeneratorExpression(const cmGeneratorExpression &);
void operator=(const cmGeneratorExpression &);
cmListFileBacktrace const& Backtrace;
cmCompiledGeneratorExpression *CompiledExpression;
};
class cmCompiledGeneratorExpression
{
public:
const char* Evaluate(cmMakefile* mf, const char* config,
bool quiet = false,
cmTarget *target = 0,
cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
/** Get set of targets found during evaluations. */
std::set<cmTarget*> const& GetTargets() const
{ return this->Targets; }
~cmCompiledGeneratorExpression();
private:
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
const std::vector<cmGeneratorExpressionEvaluator*> &evaluators,
const char *input, bool needsParsing);
friend class cmGeneratorExpression;
cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
void operator=(const cmCompiledGeneratorExpression &);
cmListFileBacktrace const& Backtrace;
const std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
const char* const Input;
const bool NeedsParsing;
mutable std::set<cmTarget*> Targets;
mutable std::string Output;
};
#endif