summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-11-25 21:47:44 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-03-09 19:48:57 (GMT)
commit5c559f11137dcb14113a3c5df99ff896c65c7596 (patch)
tree63e0fcb01e959715cd0eca161ec799f5e1048fb2 /Source
parente387ce7d681f9bd6c90c41f34b7500dfeb3b32ba (diff)
downloadCMake-5c559f11137dcb14113a3c5df99ff896c65c7596.zip
CMake-5c559f11137dcb14113a3c5df99ff896c65c7596.tar.gz
CMake-5c559f11137dcb14113a3c5df99ff896c65c7596.tar.bz2
Genex: Enable use of COMPILE_LANGUAGE for compile options.
Follow-ups will allow the use of the generator expression for compile definitions and include directories for non-IDE generators.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx34
-rw-r--r--Source/cmLocalGenerator.cxx4
-rw-r--r--Source/cmTarget.cxx26
-rw-r--r--Source/cmTarget.h3
4 files changed, 55 insertions, 12 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 63a46f2..6a9f251 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -827,6 +827,40 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
"components of the file(GENERATE) command.");
return std::string();
}
+
+ std::vector<std::string> enabledLanguages;
+ cmGlobalGenerator* gg
+ = context->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+ gg->GetEnabledLanguages(enabledLanguages);
+ if (!parameters.empty() &&
+ std::find(enabledLanguages.begin(), enabledLanguages.end(),
+ parameters.front()) == enabledLanguages.end())
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<COMPILE_LANGUAGE:...> Unknown language.");
+ return std::string();
+ }
+
+ std::string genName = gg->GetName();
+ if (genName.find("Visual Studio") != std::string::npos)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
+ "generators.");
+ return std::string();
+ }
+ else
+ {
+ if(genName.find("Makefiles") == std::string::npos &&
+ genName.find("Ninja") == std::string::npos &&
+ genName.find("Watcom WMake") == std::string::npos &&
+ genName.find("Xcode") == std::string::npos)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<COMPILE_LANGUAGE:...> not supported for this generator.");
+ return std::string();
+ }
+ }
if (parameters.empty())
{
return context->Language;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 7c83f27..be82085 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1453,7 +1453,7 @@ void cmLocalGenerator::AddCompileOptions(
{
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
}
- target->GetCompileOptions(opts, config);
+ target->GetCompileOptions(opts, config, lang);
for(std::vector<std::string>::const_iterator i = opts.begin();
i != opts.end(); ++i)
{
@@ -1474,7 +1474,7 @@ void cmLocalGenerator::AddCompileOptions(
this->AppendFlags(flags, targetFlags);
}
std::vector<std::string> opts;
- target->GetCompileOptions(opts, config);
+ target->GetCompileOptions(opts, config, lang);
for(std::vector<std::string>::const_iterator i = opts.begin();
i != opts.end(); ++i)
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e046bef..c54d694 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2192,7 +2192,8 @@ static void processCompileOptionsInternal(cmTarget const* tgt,
std::vector<std::string> &options,
UNORDERED_SET<std::string> &uniqueOptions,
cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugOptions, const char *logName)
+ const std::string& config, bool debugOptions, const char *logName,
+ std::string const& language)
{
cmMakefile *mf = tgt->GetMakefile();
@@ -2204,7 +2205,8 @@ static void processCompileOptionsInternal(cmTarget const* tgt,
config,
false,
tgt,
- dagChecker),
+ dagChecker,
+ language),
entryOptions);
std::string usedOptions;
for(std::vector<std::string>::iterator
@@ -2238,10 +2240,12 @@ static void processCompileOptions(cmTarget const* tgt,
std::vector<std::string> &options,
UNORDERED_SET<std::string> &uniqueOptions,
cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugOptions)
+ const std::string& config, bool debugOptions,
+ std::string const& language)
{
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions, "options");
+ dagChecker, config, debugOptions, "options",
+ language);
}
//----------------------------------------------------------------------------
@@ -2271,7 +2275,8 @@ void cmTarget::GetAutoUicOptions(std::vector<std::string> &result,
//----------------------------------------------------------------------------
void cmTarget::GetCompileOptions(std::vector<std::string> &result,
- const std::string& config) const
+ const std::string& config,
+ const std::string& language) const
{
UNORDERED_SET<std::string> uniqueOptions;
@@ -2303,7 +2308,8 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
uniqueOptions,
&dagChecker,
config,
- debugOptions);
+ debugOptions,
+ language);
std::vector<cmTargetInternals::TargetPropertyEntry*>
linkInterfaceCompileOptionsEntries;
@@ -2318,7 +2324,8 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
uniqueOptions,
&dagChecker,
config,
- debugOptions);
+ debugOptions,
+ language);
deleteAndClear(linkInterfaceCompileOptionsEntries);
}
@@ -2333,7 +2340,7 @@ static void processCompileDefinitions(cmTarget const* tgt,
{
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
dagChecker, config, debugOptions,
- "definitions");
+ "definitions", std::string());
}
//----------------------------------------------------------------------------
@@ -2431,7 +2438,8 @@ static void processCompileFeatures(cmTarget const* tgt,
const std::string& config, bool debugOptions)
{
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions, "features");
+ dagChecker, config, debugOptions, "features",
+ std::string());
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index ddd9859..56db22e 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -577,7 +577,8 @@ public:
void AppendBuildInterfaceIncludes();
void GetCompileOptions(std::vector<std::string> &result,
- const std::string& config) const;
+ const std::string& config,
+ const std::string& language) const;
void GetAutoUicOptions(std::vector<std::string> &result,
const std::string& config) const;
void GetCompileFeatures(std::vector<std::string> &features,