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 <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;
|
2015-02-22 23:30:44 +03:00
|
|
|
struct cmGeneratorExpressionContext;
|
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. */
|
2014-05-23 22:59:11 +04:00
|
|
|
cmGeneratorExpression(cmListFileBacktrace const* backtrace = NULL);
|
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,
|
2013-07-25 11:05:03 +04:00
|
|
|
PreprocessContext context,
|
|
|
|
bool resolveRelative = false);
|
2012-10-15 12:27:42 +04:00
|
|
|
|
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);
|
|
|
|
|
2013-02-18 14:24:41 +04:00
|
|
|
static std::string StripEmptyListElements(const std::string &input);
|
2012-09-12 17:11:25 +04:00
|
|
|
private:
|
|
|
|
cmGeneratorExpression(const cmGeneratorExpression &);
|
|
|
|
void operator=(const cmGeneratorExpression &);
|
|
|
|
|
2014-05-23 22:59:11 +04:00
|
|
|
cmListFileBacktrace const* Backtrace;
|
2012-09-12 17:11:25 +04:00
|
|
|
};
|
2010-12-08 21:34:05 +03:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
class cmCompiledGeneratorExpression
|
|
|
|
{
|
|
|
|
public:
|
2014-02-10 07:48:34 +04:00
|
|
|
const char* Evaluate(cmMakefile* mf, const std::string& config,
|
2012-09-12 06:23:31 +04:00
|
|
|
bool quiet = false,
|
2013-10-30 01:21:20 +04:00
|
|
|
cmTarget const* headTarget = 0,
|
|
|
|
cmTarget const* currentTarget = 0,
|
2015-02-22 19:43:13 +03:00
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker = 0,
|
|
|
|
std::string const& language = std::string()) const;
|
2014-02-10 07:48:34 +04:00
|
|
|
const char* Evaluate(cmMakefile* mf, const std::string& config,
|
2012-11-06 19:06:31 +04:00
|
|
|
bool quiet,
|
2013-10-30 01:21:20 +04:00
|
|
|
cmTarget const* headTarget,
|
2015-02-22 19:43:13 +03:00
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
|
|
|
std::string const& language = std::string()) 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
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> const& GetSeenTargetProperties() const
|
2012-11-05 17:48:42 +04:00
|
|
|
{ return this->SeenTargetProperties; }
|
|
|
|
|
2013-10-30 01:21:20 +04:00
|
|
|
std::set<cmTarget const*> const& GetAllTargetsSeen() const
|
2013-02-09 14:12:20 +04:00
|
|
|
{ return this->AllTargetsSeen; }
|
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
~cmCompiledGeneratorExpression();
|
|
|
|
|
2014-02-08 21:01:01 +04:00
|
|
|
std::string const& GetInput() const
|
2012-11-19 22:30:56 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2014-07-21 21:02:22 +04:00
|
|
|
bool GetHadHeadSensitiveCondition() const
|
|
|
|
{
|
|
|
|
return this->HadHeadSensitiveCondition;
|
|
|
|
}
|
2014-11-05 01:24:54 +03:00
|
|
|
std::set<cmTarget const*> GetSourceSensitiveTargets() const
|
|
|
|
{
|
|
|
|
return this->SourceSensitiveTargets;
|
|
|
|
}
|
2012-12-18 19:16:14 +04:00
|
|
|
|
2014-03-20 18:37:12 +04:00
|
|
|
void SetEvaluateForBuildsystem(bool eval)
|
|
|
|
{
|
|
|
|
this->EvaluateForBuildsystem = eval;
|
|
|
|
}
|
|
|
|
|
2014-05-15 13:32:30 +04:00
|
|
|
void GetMaxLanguageStandard(cmTarget const* tgt,
|
|
|
|
std::map<std::string, std::string>& mapping);
|
|
|
|
|
2009-08-11 17:54:56 +04:00
|
|
|
private:
|
2015-02-22 23:30:44 +03:00
|
|
|
const char* EvaluateWithContext(cmGeneratorExpressionContext& context,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const;
|
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
|
2014-02-08 21:01:01 +04:00
|
|
|
const std::string& 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;
|
2013-02-28 15:04:23 +04:00
|
|
|
bool NeedsEvaluation;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2013-02-09 14:12:20 +04:00
|
|
|
mutable std::set<cmTarget*> DependTargets;
|
2013-10-30 01:21:20 +04:00
|
|
|
mutable std::set<cmTarget const*> AllTargetsSeen;
|
2014-02-10 09:21:34 +04:00
|
|
|
mutable std::set<std::string> SeenTargetProperties;
|
2014-05-15 13:32:30 +04:00
|
|
|
mutable std::map<cmTarget const*, std::map<std::string, std::string> >
|
|
|
|
MaxLanguageStandard;
|
2012-09-12 17:11:25 +04:00
|
|
|
mutable std::string Output;
|
2013-02-03 10:33:15 +04:00
|
|
|
mutable bool HadContextSensitiveCondition;
|
2014-07-21 21:02:22 +04:00
|
|
|
mutable bool HadHeadSensitiveCondition;
|
2014-11-05 01:24:54 +03:00
|
|
|
mutable std::set<cmTarget const*> SourceSensitiveTargets;
|
2014-03-20 18:37:12 +04:00
|
|
|
bool EvaluateForBuildsystem;
|
2009-08-11 17:54:56 +04:00
|
|
|
};
|
2012-09-20 02:18:23 +04:00
|
|
|
|
|
|
|
#endif
|