summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-02-22 16:43:13 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-03-07 12:19:45 (GMT)
commite387ce7d681f9bd6c90c41f34b7500dfeb3b32ba (patch)
tree0ba79cecd48ff485649045fcfdde434492c8ecb5 /Source
parent4a0128f42feb7da9b6bebe0c2c3aa7a756b96822 (diff)
downloadCMake-e387ce7d681f9bd6c90c41f34b7500dfeb3b32ba.zip
CMake-e387ce7d681f9bd6c90c41f34b7500dfeb3b32ba.tar.gz
CMake-e387ce7d681f9bd6c90c41f34b7500dfeb3b32ba.tar.bz2
Genex: Add a COMPILE_LANGUAGE generator expression.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpression.cxx10
-rw-r--r--Source/cmGeneratorExpression.h6
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx32
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h1
4 files changed, 43 insertions, 6 deletions
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index bf96951..0a27016 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -52,14 +52,16 @@ cmGeneratorExpression::~cmGeneratorExpression()
const char *cmCompiledGeneratorExpression::Evaluate(
cmMakefile* mf, const std::string& config, bool quiet,
cmTarget const* headTarget,
- cmGeneratorExpressionDAGChecker *dagChecker) const
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ std::string const& language) const
{
return this->Evaluate(mf,
config,
quiet,
headTarget,
headTarget,
- dagChecker);
+ dagChecker,
+ language);
}
//----------------------------------------------------------------------------
@@ -67,7 +69,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(
cmMakefile* mf, const std::string& config, bool quiet,
cmTarget const* headTarget,
cmTarget const* currentTarget,
- cmGeneratorExpressionDAGChecker *dagChecker) const
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ std::string const& language) const
{
if (!this->NeedsEvaluation)
{
@@ -93,6 +96,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
context.Backtrace = this->Backtrace;
+ context.Language = language;
for ( ; it != end; ++it)
{
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 57f78c5..55d9691 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -80,11 +80,13 @@ public:
bool quiet = false,
cmTarget const* headTarget = 0,
cmTarget const* currentTarget = 0,
- cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
+ cmGeneratorExpressionDAGChecker *dagChecker = 0,
+ std::string const& language = std::string()) const;
const char* Evaluate(cmMakefile* mf, const std::string& config,
bool quiet,
cmTarget const* headTarget,
- cmGeneratorExpressionDAGChecker *dagChecker) const;
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ std::string const& language = std::string()) const;
/** Get set of targets found during evaluations. */
std::set<cmTarget*> const& GetTargets() const
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index ba18faa..63a46f2 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -16,6 +16,7 @@
#include "cmGeneratorExpressionDAGChecker.h"
#include "cmGeneratorExpression.h"
#include "cmLocalGenerator.h"
+#include "cmGlobalGenerator.h"
#include "cmSourceFile.h"
#include <cmsys/String.h>
@@ -89,7 +90,8 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
context->Quiet,
headTarget,
currentTarget,
- dagChecker);
+ dagChecker,
+ context->Language);
if (cge->GetHadContextSensitiveCondition())
{
context->HadContextSensitiveCondition = true;
@@ -806,6 +808,33 @@ static const struct JoinNode : public cmGeneratorExpressionNode
}
} joinNode;
+static const struct CompileLanguageNode : public cmGeneratorExpressionNode
+{
+ CompileLanguageNode() {}
+
+ virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ if(context->Language.empty())
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<COMPILE_LANGUAGE:...> may only be used to specify include "
+ "directories compile definitions, compile options and to evaluate "
+ "components of the file(GENERATE) command.");
+ return std::string();
+ }
+ if (parameters.empty())
+ {
+ return context->Language;
+ }
+ return context->Language == parameters.front() ? "1" : "0";
+ }
+} languageNode;
+
#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
, "INTERFACE_" #PROPERTY
@@ -1829,6 +1858,7 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
nodeMap["JOIN"] = &joinNode;
nodeMap["LINK_ONLY"] = &linkOnlyNode;
+ nodeMap["COMPILE_LANGUAGE"] = &languageNode;
}
NodeMap::const_iterator i = nodeMap.find(identifier);
if (i == nodeMap.end())
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 0bf1797..b1fec0b 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -36,6 +36,7 @@ struct cmGeneratorExpressionContext
MaxLanguageStandard;
cmMakefile *Makefile;
std::string Config;
+ std::string Language;
cmTarget const* HeadTarget; // The target whose property is being evaluated.
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
// directly or indirectly in the property.