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
|
|
|
|
|
2016-09-01 21:05:48 +03:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
|
2012-11-19 22:30:56 +04:00
|
|
|
#include "cmListFileCache.h"
|
2009-08-11 17:54:56 +04:00
|
|
|
|
2016-06-28 17:17:52 +03:00
|
|
|
#include <cm_auto_ptr.hxx>
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2009-08-11 17:54:56 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
class cmCompiledGeneratorExpression;
|
2015-09-16 05:38:52 +03:00
|
|
|
class cmGeneratorTarget;
|
2015-07-25 17:56:52 +03:00
|
|
|
class cmLocalGenerator;
|
2015-02-22 23:30:44 +03:00
|
|
|
struct cmGeneratorExpressionContext;
|
2012-09-18 15:42:23 +04:00
|
|
|
struct cmGeneratorExpressionDAGChecker;
|
2016-09-01 21:59:28 +03:00
|
|
|
struct cmGeneratorExpressionEvaluator;
|
2012-09-12 17:11:25 +04:00
|
|
|
|
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. */
|
2015-07-09 00:52:51 +03:00
|
|
|
cmGeneratorExpression(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmListFileBacktrace const& backtrace = cmListFileBacktrace());
|
2012-09-11 21:53:38 +04:00
|
|
|
~cmGeneratorExpression();
|
|
|
|
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(std::string const& input);
|
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(const char* input);
|
2012-09-12 17:11:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
enum PreprocessContext
|
|
|
|
{
|
2012-09-23 15:16:44 +04:00
|
|
|
StripAllGeneratorExpressions,
|
|
|
|
BuildInterface,
|
|
|
|
InstallInterface
|
2012-10-15 12:27:42 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03: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
|
|
|
|
2016-05-16 17:34:04 +03: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 15:00:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static bool IsValidTargetName(const std::string& input);
|
2013-02-06 16:18:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static std::string StripEmptyListElements(const std::string& input);
|
2013-02-06 16:32:15 +04:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
private:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorExpression(const cmGeneratorExpression&);
|
|
|
|
void operator=(const cmGeneratorExpression&);
|
2012-09-12 17:11:25 +04:00
|
|
|
|
2015-07-09 00:52:51 +03:00
|
|
|
cmListFileBacktrace 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:
|
2016-06-27 23:44:16 +03: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 17:56:52 +03:00
|
|
|
const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
bool quiet, cmGeneratorTarget const* headTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker,
|
2015-02-22 19:43:13 +03:00
|
|
|
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. */
|
2015-10-10 19:41:51 +03:00
|
|
|
std::set<cmGeneratorTarget*> const& GetTargets() const
|
2016-05-16 17:34:04 +03: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
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
return this->SeenTargetProperties;
|
|
|
|
}
|
2012-11-05 17:48:42 +04:00
|
|
|
|
2015-10-10 19:41:51 +03:00
|
|
|
std::set<cmGeneratorTarget const*> const& GetAllTargetsSeen() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
return this->AllTargetsSeen;
|
|
|
|
}
|
2013-02-09 14:12:20 +04:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
~cmCompiledGeneratorExpression();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& GetInput() const { return this->Input; }
|
2012-11-19 22:30:56 +04:00
|
|
|
|
2016-05-16 17:34:04 +03: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;
|
|
|
|
}
|
2015-10-10 19:41:51 +03:00
|
|
|
std::set<cmGeneratorTarget const*> GetSourceSensitiveTargets() const
|
2014-11-05 01:24:54 +03:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-10-10 19:41:51 +03:00
|
|
|
void GetMaxLanguageStandard(cmGeneratorTarget const* tgt,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<std::string, std::string>& mapping);
|
2014-05-15 13:32:30 +04:00
|
|
|
|
2009-08-11 17:54:56 +04:00
|
|
|
private:
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* EvaluateWithContext(
|
|
|
|
cmGeneratorExpressionContext& context,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const;
|
2015-02-22 23:30:44 +03:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& input);
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2012-09-12 17:11:25 +04:00
|
|
|
friend class cmGeneratorExpression;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression&);
|
|
|
|
void operator=(const cmCompiledGeneratorExpression&);
|
2012-09-12 17:11:25 +04:00
|
|
|
|
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
|
|
|
|
2015-10-10 19:41:51 +03:00
|
|
|
mutable std::set<cmGeneratorTarget*> DependTargets;
|
|
|
|
mutable std::set<cmGeneratorTarget const*> AllTargetsSeen;
|
2014-02-10 09:21:34 +04:00
|
|
|
mutable std::set<std::string> SeenTargetProperties;
|
2015-10-10 19:41:51 +03:00
|
|
|
mutable std::map<cmGeneratorTarget const*,
|
2016-05-16 17:34:04 +03:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
mutable std::set<cmGeneratorTarget 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
|