summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpression.h
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@sap.com>2017-12-01 16:10:45 (GMT)
committerBrad King <brad.king@kitware.com>2017-12-04 14:10:09 (GMT)
commit6bffc13ef1c85ec565273d25e811fd6c326533f0 (patch)
tree752484518da79d7edfe4ba98880f1ce7d694478c /Source/cmGeneratorExpression.h
parenta4faf8638744edf7e3dd8931b55ba87e8f7738be (diff)
downloadCMake-6bffc13ef1c85ec565273d25e811fd6c326533f0.zip
CMake-6bffc13ef1c85ec565273d25e811fd6c326533f0.tar.gz
CMake-6bffc13ef1c85ec565273d25e811fd6c326533f0.tar.bz2
Refactor per-source generator expression evaluation
Prepare to add generator expression support to more source properties. Factor out some duplicated code into a helper to avoid further duplication.
Diffstat (limited to 'Source/cmGeneratorExpression.h')
-rw-r--r--Source/cmGeneratorExpression.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index cface0d..611fbf8 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -153,4 +153,54 @@ private:
bool EvaluateForBuildsystem;
};
+class cmGeneratorExpressionInterpreter
+{
+ CM_DISABLE_COPY(cmGeneratorExpressionInterpreter)
+
+public:
+ cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator,
+ cmGeneratorTarget* generatorTarget,
+ const std::string& config)
+ : LocalGenerator(localGenerator)
+ , GeneratorTarget(generatorTarget)
+ , Config(config)
+ {
+ }
+
+ const char* Evaluate(const char* expression)
+ {
+ this->CompiledGeneratorExpression =
+ this->GeneratorExpression.Parse(expression);
+
+ return this->CompiledGeneratorExpression->Evaluate(
+ this->LocalGenerator, this->Config, false, this->GeneratorTarget);
+ }
+ const char* Evaluate(const std::string& expression)
+ {
+ return this->Evaluate(expression.c_str());
+ }
+
+protected:
+ cmGeneratorExpression& GetGeneratorExpression()
+ {
+ return this->GeneratorExpression;
+ }
+
+ cmCompiledGeneratorExpression& GetCompiledGeneratorExpression()
+ {
+ return *(this->CompiledGeneratorExpression);
+ }
+
+ cmLocalGenerator* GetLocalGenerator() { return this->LocalGenerator; }
+
+ cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget; }
+
+private:
+ cmGeneratorExpression GeneratorExpression;
+ std::unique_ptr<cmCompiledGeneratorExpression> CompiledGeneratorExpression;
+ cmLocalGenerator* LocalGenerator = nullptr;
+ cmGeneratorTarget* GeneratorTarget = nullptr;
+ std::string Config;
+};
+
#endif