2016-09-27 15:01:08 -04:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2012-09-20 00:18:23 +02:00
|
|
|
#ifndef cmGeneratorExpression_h
|
|
|
|
#define cmGeneratorExpression_h
|
|
|
|
|
2016-09-01 20:05:48 +02:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
|
2012-11-19 19:30:56 +01:00
|
|
|
#include "cmListFileCache.h"
|
2009-08-11 09:54:56 -04:00
|
|
|
|
2016-06-28 10:17:52 -04:00
|
|
|
#include <cm_auto_ptr.hxx>
|
2016-09-01 20:59:28 +02:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2009-08-11 09:54:56 -04:00
|
|
|
|
2016-09-01 20:59:28 +02:00
|
|
|
class cmCompiledGeneratorExpression;
|
2015-09-16 04:38:52 +02:00
|
|
|
class cmGeneratorTarget;
|
2015-07-25 16:56:52 +02:00
|
|
|
class cmLocalGenerator;
|
2015-02-22 21:30:44 +01:00
|
|
|
struct cmGeneratorExpressionContext;
|
2012-09-18 13:42:23 +02:00
|
|
|
struct cmGeneratorExpressionDAGChecker;
|
2016-09-01 20:59:28 +02:00
|
|
|
struct cmGeneratorExpressionEvaluator;
|
2012-09-12 15:11:25 +02:00
|
|
|
|
2009-08-11 09: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 15:11:25 +02:00
|
|
|
/** Construct. */
|
2015-07-08 23:52:51 +02:00
|
|
|
cmGeneratorExpression(
|
2016-05-16 10:34:04 -04:00
|
|
|
cmListFileBacktrace const& backtrace = cmListFileBacktrace());
|
2012-09-11 19:53:38 +02:00
|
|
|
~cmGeneratorExpression();
|
|
|
|
|
2016-06-28 10:17:52 -04:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(std::string const& input);
|
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(const char* input);
|
2012-09-12 15:11:25 +02:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
enum PreprocessContext
|
|
|
|
{
|
2012-09-23 13:16:44 +02:00
|
|
|
StripAllGeneratorExpressions,
|
|
|
|
BuildInterface,
|
|
|
|
InstallInterface
|
2012-10-15 10:27:42 +02:00
|
|
|
};
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static std::string Preprocess(const std::string& input,
|
2013-07-25 09:05:03 +02:00
|
|
|
PreprocessContext context,
|
|
|
|
bool resolveRelative = false);
|
2012-10-15 10:27:42 +02:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static void Split(const std::string& input,
|
|
|
|
std::vector<std::string>& output);
|
|
|
|
|
|
|
|
static std::string::size_type Find(const std::string& input);
|
2012-12-10 12:00:34 +01:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static bool IsValidTargetName(const std::string& input);
|
2013-02-06 13:18:10 +01:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
static std::string StripEmptyListElements(const std::string& input);
|
2013-02-06 13:32:15 +01:00
|
|
|
|
2012-09-12 15:11:25 +02:00
|
|
|
private:
|
2016-05-16 10:34:04 -04:00
|
|
|
cmGeneratorExpression(const cmGeneratorExpression&);
|
|
|
|
void operator=(const cmGeneratorExpression&);
|
2012-09-12 15:11:25 +02:00
|
|
|
|
2015-07-08 23:52:51 +02:00
|
|
|
cmListFileBacktrace Backtrace;
|
2012-09-12 15:11:25 +02:00
|
|
|
};
|
2010-12-08 13:34:05 -05:00
|
|
|
|
2012-09-12 15:11:25 +02:00
|
|
|
class cmCompiledGeneratorExpression
|
|
|
|
{
|
|
|
|
public:
|
2016-06-27 22:44:16 +02:00
|
|
|
const char* Evaluate(
|
|
|
|
cmLocalGenerator* lg, const std::string& config, bool quiet = false,
|
|
|
|
cmGeneratorTarget const* headTarget = CM_NULLPTR,
|
|
|
|
cmGeneratorTarget const* currentTarget = CM_NULLPTR,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker = CM_NULLPTR,
|
|
|
|
std::string const& language = std::string()) const;
|
2015-07-25 16:56:52 +02:00
|
|
|
const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
|
2016-05-16 10:34:04 -04:00
|
|
|
bool quiet, cmGeneratorTarget const* headTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker,
|
2015-02-22 17:43:13 +01:00
|
|
|
std::string const& language = std::string()) const;
|
2012-09-11 19:53:38 +02:00
|
|
|
|
2010-12-08 13:34:05 -05:00
|
|
|
/** Get set of targets found during evaluations. */
|
2015-10-10 18:41:51 +02:00
|
|
|
std::set<cmGeneratorTarget*> const& GetTargets() const
|
2016-05-16 10:34:04 -04:00
|
|
|
{
|
|
|
|
return this->DependTargets;
|
|
|
|
}
|
2012-09-12 15:11:25 +02:00
|
|
|
|
2014-02-10 00:21:34 -05:00
|
|
|
std::set<std::string> const& GetSeenTargetProperties() const
|
2016-05-16 10:34:04 -04:00
|
|
|
{
|
|
|
|
return this->SeenTargetProperties;
|
|
|
|
}
|
2012-11-05 14:48:42 +01:00
|
|
|
|
2015-10-10 18:41:51 +02:00
|
|
|
std::set<cmGeneratorTarget const*> const& GetAllTargetsSeen() const
|
2016-05-16 10:34:04 -04:00
|
|
|
{
|
|
|
|
return this->AllTargetsSeen;
|
|
|
|
}
|
2013-02-09 11:12:20 +01:00
|
|
|
|
2012-09-12 15:11:25 +02:00
|
|
|
~cmCompiledGeneratorExpression();
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
std::string const& GetInput() const { return this->Input; }
|
2012-11-19 19:30:56 +01:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
cmListFileBacktrace GetBacktrace() const { return this->Backtrace; }
|
2013-02-03 07:33:15 +01:00
|
|
|
bool GetHadContextSensitiveCondition() const
|
|
|
|
{
|
|
|
|
return this->HadContextSensitiveCondition;
|
|
|
|
}
|
2014-07-21 13:02:22 -04:00
|
|
|
bool GetHadHeadSensitiveCondition() const
|
|
|
|
{
|
|
|
|
return this->HadHeadSensitiveCondition;
|
|
|
|
}
|
2015-10-10 18:41:51 +02:00
|
|
|
std::set<cmGeneratorTarget const*> GetSourceSensitiveTargets() const
|
2014-11-04 23:24:54 +01:00
|
|
|
{
|
|
|
|
return this->SourceSensitiveTargets;
|
|
|
|
}
|
2012-12-18 16:16:14 +01:00
|
|
|
|
2014-03-20 15:37:12 +01:00
|
|
|
void SetEvaluateForBuildsystem(bool eval)
|
|
|
|
{
|
|
|
|
this->EvaluateForBuildsystem = eval;
|
|
|
|
}
|
|
|
|
|
2015-10-10 18:41:51 +02:00
|
|
|
void GetMaxLanguageStandard(cmGeneratorTarget const* tgt,
|
2016-05-16 10:34:04 -04:00
|
|
|
std::map<std::string, std::string>& mapping);
|
2014-05-15 11:32:30 +02:00
|
|
|
|
2009-08-11 09:54:56 -04:00
|
|
|
private:
|
2016-05-16 10:34:04 -04:00
|
|
|
const char* EvaluateWithContext(
|
|
|
|
cmGeneratorExpressionContext& context,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const;
|
2015-02-22 21:30:44 +01:00
|
|
|
|
2012-09-12 15:11:25 +02:00
|
|
|
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
|
2016-05-16 10:34:04 -04:00
|
|
|
const std::string& input);
|
2012-09-11 19:53:38 +02:00
|
|
|
|
2012-09-12 15:11:25 +02:00
|
|
|
friend class cmGeneratorExpression;
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression&);
|
|
|
|
void operator=(const cmCompiledGeneratorExpression&);
|
2012-09-12 15:11:25 +02:00
|
|
|
|
2012-11-19 19:30:56 +01:00
|
|
|
cmListFileBacktrace Backtrace;
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
|
|
|
|
const std::string Input;
|
2013-02-28 12:04:23 +01:00
|
|
|
bool NeedsEvaluation;
|
2012-09-11 19:53:38 +02:00
|
|
|
|
2015-10-10 18:41:51 +02:00
|
|
|
mutable std::set<cmGeneratorTarget*> DependTargets;
|
|
|
|
mutable std::set<cmGeneratorTarget const*> AllTargetsSeen;
|
2014-02-10 00:21:34 -05:00
|
|
|
mutable std::set<std::string> SeenTargetProperties;
|
2015-10-10 18:41:51 +02:00
|
|
|
mutable std::map<cmGeneratorTarget const*,
|
2016-05-16 10:34:04 -04:00
|
|
|
std::map<std::string, std::string> >
|
|
|
|
MaxLanguageStandard;
|
2012-09-12 15:11:25 +02:00
|
|
|
mutable std::string Output;
|
2013-02-03 07:33:15 +01:00
|
|
|
mutable bool HadContextSensitiveCondition;
|
2014-07-21 13:02:22 -04:00
|
|
|
mutable bool HadHeadSensitiveCondition;
|
2016-05-16 10:34:04 -04:00
|
|
|
mutable std::set<cmGeneratorTarget const*> SourceSensitiveTargets;
|
2014-03-20 15:37:12 +01:00
|
|
|
bool EvaluateForBuildsystem;
|
2009-08-11 09:54:56 -04:00
|
|
|
};
|
2012-09-20 00:18:23 +02:00
|
|
|
|
|
|
|
#endif
|