2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-08-11 17:54:56 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2009-08-11 17:54:56 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2012-09-20 02:18:23 +04:00
|
|
|
|
|
|
|
#ifndef cmGeneratorExpression_h
|
|
|
|
#define cmGeneratorExpression_h
|
|
|
|
|
2009-08-11 17:54:56 +04:00
|
|
|
#include "cmStandardIncludes.h"
|
2012-11-19 22:30:56 +04:00
|
|
|
#include "cmListFileCache.h"
|
2009-08-11 17:54:56 +04:00
|
|
|
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2012-11-19 22:30:56 +04:00
|
|
|
#include <cmsys/auto_ptr.hxx>
|
2009-08-11 17:54:56 +04:00
|
|
|
|
2010-12-08 21:34:05 +03:00
|
|
|
class cmTarget;
|
2009-08-11 17:54:56 +04:00
|
|
|
class cmMakefile;
|
|
|
|
class cmListFileBacktrace;
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
struct cmGeneratorExpressionEvaluator;
|
2012-09-18 15:42:23 +04:00
|
|
|
struct cmGeneratorExpressionDAGChecker;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
class cmCompiledGeneratorExpression;
|
|
|
|
|
2009-08-11 17:54:56 +04:00
|
|
|
/** \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:
|
2012-09-12 17:11:25 +04:00
|
|
|
/** Construct. */
|
|
|
|
cmGeneratorExpression(cmListFileBacktrace const& backtrace);
|
2012-09-11 21:53:38 +04:00
|
|
|
~cmGeneratorExpression();
|
|
|
|
|
2012-11-19 22:30:56 +04:00
|
|
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(
|
|
|
|
std::string const& input);
|
|
|
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
|
2012-09-12 17:11:25 +04:00
|
|
|
|
2012-10-15 12:27:42 +04:00
|
|
|
enum PreprocessContext {
|
2012-09-23 15:16:44 +04:00
|
|
|
StripAllGeneratorExpressions,
|
|
|
|
BuildInterface,
|
|
|
|
InstallInterface
|
2012-10-15 12:27:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static std::string Preprocess(const std::string &input,
|
|
|
|
PreprocessContext context);
|
|
|
|
|
2012-12-10 15:00:34 +04:00
|
|
|
static void Split(const std::string &input,
|
|
|
|
std::vector<std::string> &output);
|
|
|
|
|
2013-02-06 16:18:10 +04:00
|
|
|
static std::string::size_type Find(const std::string &input);
|
|
|
|
|
2013-02-06 16:32:15 +04:00
|
|
|
static bool IsValidTargetName(const std::string &input);
|
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
private:
|
|
|
|
cmGeneratorExpression(const cmGeneratorExpression &);
|
|
|
|
void operator=(const cmGeneratorExpression &);
|
|
|
|
|
|
|
|
cmListFileBacktrace const& Backtrace;
|
|
|
|
};
|
2010-12-08 21:34:05 +03:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
class cmCompiledGeneratorExpression
|
|
|
|
{
|
|
|
|
public:
|
2012-09-11 21:53:38 +04:00
|
|
|
const char* Evaluate(cmMakefile* mf, const char* config,
|
2012-09-12 06:23:31 +04:00
|
|
|
bool quiet = false,
|
2012-11-06 19:06:31 +04:00
|
|
|
cmTarget *headTarget = 0,
|
|
|
|
cmTarget *currentTarget = 0,
|
2012-09-18 15:42:23 +04:00
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
|
2012-11-06 19:06:31 +04:00
|
|
|
const char* Evaluate(cmMakefile* mf, const char* config,
|
|
|
|
bool quiet,
|
|
|
|
cmTarget *headTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2010-12-08 21:34:05 +03:00
|
|
|
/** Get set of targets found during evaluations. */
|
|
|
|
std::set<cmTarget*> const& GetTargets() const
|
2013-02-09 14:12:20 +04:00
|
|
|
{ return this->DependTargets; }
|
2012-09-12 17:11:25 +04:00
|
|
|
|
2013-02-07 16:04:46 +04:00
|
|
|
std::set<cmStdString> const& GetSeenTargetProperties() const
|
2012-11-05 17:48:42 +04:00
|
|
|
{ return this->SeenTargetProperties; }
|
|
|
|
|
2013-02-09 14:12:20 +04:00
|
|
|
std::set<cmTarget*> const& GetAllTargetsSeen() const
|
|
|
|
{ return this->AllTargetsSeen; }
|
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
~cmCompiledGeneratorExpression();
|
|
|
|
|
2012-11-19 22:30:56 +04:00
|
|
|
std::string GetInput() const
|
|
|
|
{
|
|
|
|
return this->Input;
|
|
|
|
}
|
|
|
|
|
2012-12-18 19:16:14 +04:00
|
|
|
cmListFileBacktrace GetBacktrace() const
|
|
|
|
{
|
|
|
|
return this->Backtrace;
|
|
|
|
}
|
2013-02-03 10:33:15 +04:00
|
|
|
bool GetHadContextSensitiveCondition() const
|
|
|
|
{
|
|
|
|
return this->HadContextSensitiveCondition;
|
|
|
|
}
|
2012-12-18 19:16:14 +04:00
|
|
|
|
2009-08-11 17:54:56 +04:00
|
|
|
private:
|
2012-09-12 17:11:25 +04:00
|
|
|
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
|
2012-11-19 22:30:56 +04:00
|
|
|
const char *input);
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
friend class cmGeneratorExpression;
|
|
|
|
|
|
|
|
cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
|
|
|
|
void operator=(const cmCompiledGeneratorExpression &);
|
|
|
|
|
2012-11-19 22:30:56 +04:00
|
|
|
cmListFileBacktrace Backtrace;
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
|
|
|
|
const std::string Input;
|
|
|
|
bool NeedsParsing;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2013-02-09 14:12:20 +04:00
|
|
|
mutable std::set<cmTarget*> DependTargets;
|
|
|
|
mutable std::set<cmTarget*> AllTargetsSeen;
|
2013-02-07 16:04:46 +04:00
|
|
|
mutable std::set<cmStdString> SeenTargetProperties;
|
2012-09-12 17:11:25 +04:00
|
|
|
mutable std::string Output;
|
2013-02-03 10:33:15 +04:00
|
|
|
mutable bool HadContextSensitiveCondition;
|
2009-08-11 17:54:56 +04:00
|
|
|
};
|
2012-09-20 02:18:23 +04:00
|
|
|
|
|
|
|
#endif
|