summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-09-06 20:49:34 (GMT)
committerBrad King <brad.king@kitware.com>2018-09-07 13:23:43 (GMT)
commit1b57f49586afc9e8663d5e146732b1cd0597e7ef (patch)
tree3754c4403d6b5cc3f5e6b2543f6e1f394dc92ea7 /Source
parentbea390e9bd68e1aa7d86b6aef7384f502c39068c (diff)
downloadCMake-1b57f49586afc9e8663d5e146732b1cd0597e7ef.zip
CMake-1b57f49586afc9e8663d5e146732b1cd0597e7ef.tar.gz
CMake-1b57f49586afc9e8663d5e146732b1cd0597e7ef.tar.bz2
genex: Simplify cmGeneratorExpressionInterpreter
All callers were constructing with a non-empty target name using the target whose pointer was passed anyway. Drop this argument. Simplify logic accordingly. Re-order constructor arguments to match the cmCompiledGeneratorExpression::Evaluate arguments. Also remove unnecessary getters.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx12
-rw-r--r--Source/cmGeneratorExpression.cxx15
-rw-r--r--Source/cmGeneratorExpression.h55
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx12
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx11
-rw-r--r--Source/cmServerProtocol.cxx9
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx3
9 files changed, 36 insertions, 87 deletions
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 14e7927..c4cca07 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -354,8 +354,8 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
lg->GetTargetCompileFlags(gtgt, config, language, flags);
// Add source file specific flags.
- cmGeneratorExpressionInterpreter genexInterpreter(lg, gtgt, config,
- gtgt->GetName(), language);
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, gtgt,
+ language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
@@ -381,8 +381,8 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines(
cmMakefile* makefile = lg->GetMakefile();
const std::string& language = source->GetLanguage();
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- cmGeneratorExpressionInterpreter genexInterpreter(
- lg, target, config, target->GetName(), language);
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
+ language);
// Add the export symbol definition for shared library objects.
if (const char* exportMacro = target->GetExportMacro()) {
@@ -419,8 +419,8 @@ std::string cmExtraSublimeTextGenerator::ComputeIncludes(
cmMakefile* makefile = lg->GetMakefile();
const std::string& language = source->GetLanguage();
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- cmGeneratorExpressionInterpreter genexInterpreter(
- lg, target, config, target->GetName(), language);
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
+ language);
// Add include directories for this source file
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 6823cd5..6d83a3f 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -13,6 +13,7 @@
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h"
+#include "cmGeneratorTarget.h"
#include "cmSystemTools.h"
cmGeneratorExpression::cmGeneratorExpression(
@@ -389,14 +390,16 @@ void cmCompiledGeneratorExpression::GetMaxLanguageStandard(
const std::string& cmGeneratorExpressionInterpreter::Evaluate(
const char* expression, const std::string& property)
{
- if (this->Target.empty()) {
- return this->EvaluateExpression(expression);
- }
+ this->CompiledGeneratorExpression =
+ this->GeneratorExpression.Parse(expression);
// Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS
cmGeneratorExpressionDAGChecker dagChecker(
- this->Target, property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property,
- nullptr, nullptr);
+ this->HeadTarget->GetName(),
+ property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr,
+ nullptr);
- return this->EvaluateExpression(expression, &dagChecker);
+ return this->CompiledGeneratorExpression->Evaluate(
+ this->LocalGenerator, this->Config, false, this->HeadTarget, &dagChecker,
+ this->Language);
}
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 2b7df91..8176d5c 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -160,24 +160,15 @@ class cmGeneratorExpressionInterpreter
public:
cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator,
- cmGeneratorTarget* generatorTarget,
- const std::string& config,
- const std::string& target,
- const std::string& lang)
+ std::string const& config,
+ cmGeneratorTarget const* headTarget,
+ std::string const& lang = std::string())
: LocalGenerator(localGenerator)
- , GeneratorTarget(generatorTarget)
, Config(config)
- , Target(target)
+ , HeadTarget(headTarget)
, Language(lang)
{
}
- cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator,
- cmGeneratorTarget* generatorTarget,
- const std::string& config)
- : cmGeneratorExpressionInterpreter(localGenerator, generatorTarget, config,
- std::string(), std::string())
- {
- }
const std::string& Evaluate(const char* expression,
const std::string& property);
@@ -188,47 +179,11 @@ public:
}
protected:
- cmGeneratorExpression& GetGeneratorExpression()
- {
- return this->GeneratorExpression;
- }
-
- cmCompiledGeneratorExpression& GetCompiledGeneratorExpression()
- {
- return *(this->CompiledGeneratorExpression);
- }
-
- cmLocalGenerator* GetLocalGenerator() { return this->LocalGenerator; }
-
- cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget; }
-
- const std::string& GetTargetName() const { return this->Target; }
- const std::string& GetLanguage() const { return this->Language; }
-
- const std::string& EvaluateExpression(
- const char* expression,
- cmGeneratorExpressionDAGChecker* dagChecker = nullptr)
- {
- this->CompiledGeneratorExpression =
- this->GeneratorExpression.Parse(expression);
-
- if (dagChecker == nullptr) {
- return this->CompiledGeneratorExpression->Evaluate(
- this->LocalGenerator, this->Config, false, this->GeneratorTarget);
- }
-
- return this->CompiledGeneratorExpression->Evaluate(
- this->LocalGenerator, this->Config, false, this->GeneratorTarget,
- dagChecker, this->Language);
- }
-
-private:
cmGeneratorExpression GeneratorExpression;
std::unique_ptr<cmCompiledGeneratorExpression> CompiledGeneratorExpression;
cmLocalGenerator* LocalGenerator = nullptr;
- cmGeneratorTarget* GeneratorTarget = nullptr;
std::string Config;
- std::string Target;
+ cmGeneratorTarget const* HeadTarget = nullptr;
std::string Language;
};
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 7456d3c..e353a37 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -751,11 +751,10 @@ class XCodeGeneratorExpressionInterpreter
public:
XCodeGeneratorExpressionInterpreter(cmSourceFile* sourceFile,
cmLocalGenerator* localGenerator,
- cmGeneratorTarget* generatorTarget,
+ cmGeneratorTarget* headTarget,
const std::string& lang)
- : cmGeneratorExpressionInterpreter(localGenerator, generatorTarget,
- "NO-PER-CONFIG-SUPPORT-IN-XCODE",
- generatorTarget->GetName(), lang)
+ : cmGeneratorExpressionInterpreter(
+ localGenerator, "NO-PER-CONFIG-SUPPORT-IN-XCODE", headTarget, lang)
, SourceFile(sourceFile)
{
}
@@ -767,8 +766,7 @@ public:
{
const std::string& processed =
this->cmGeneratorExpressionInterpreter::Evaluate(expression, property);
- if (this->GetCompiledGeneratorExpression()
- .GetHadContextSensitiveCondition()) {
+ if (this->CompiledGeneratorExpression->GetHadContextSensitiveCondition()) {
std::ostringstream e;
/* clang-format off */
e <<
@@ -777,7 +775,7 @@ public:
"specified for source:\n"
" " << this->SourceFile->GetFullPath() << "\n";
/* clang-format on */
- this->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
}
return processed;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 13bd214..c05b085 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1497,8 +1497,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
lang = sourceLang;
}
- cmGeneratorExpressionInterpreter genexInterpreter(lg, gt, *i,
- gt->GetName(), lang);
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, *i, gt, lang);
bool needfc = false;
if (!objectName.empty()) {
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e8cf255..c8dc392 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -434,8 +434,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::string config = this->LocalGenerator->GetConfigName();
std::string configUpper = cmSystemTools::UpperCase(config);
cmGeneratorExpressionInterpreter genexInterpreter(
- this->LocalGenerator, this->GeneratorTarget, config,
- this->GeneratorTarget->GetName(), lang);
+ this->LocalGenerator, config, this->GeneratorTarget, lang);
// Add Fortran format flags.
if (lang == "Fortran") {
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 1cfaac5..ebcc501 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -136,9 +136,8 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
// Add source file specific flags.
cmGeneratorExpressionInterpreter genexInterpreter(
- this->LocalGenerator, this->GeneratorTarget,
- this->LocalGenerator->GetConfigName(), this->GeneratorTarget->GetName(),
- language);
+ this->LocalGenerator, this->LocalGenerator->GetConfigName(),
+ this->GeneratorTarget, language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
@@ -188,8 +187,7 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
std::set<std::string> defines;
const std::string config = this->LocalGenerator->GetConfigName();
cmGeneratorExpressionInterpreter genexInterpreter(
- this->LocalGenerator, this->GeneratorTarget, config,
- this->GeneratorTarget->GetName(), language);
+ this->LocalGenerator, config, this->GeneratorTarget, language);
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
@@ -217,8 +215,7 @@ std::string cmNinjaTargetGenerator::ComputeIncludes(
std::vector<std::string> includes;
const std::string config = this->LocalGenerator->GetConfigName();
cmGeneratorExpressionInterpreter genexInterpreter(
- this->LocalGenerator, this->GeneratorTarget, config,
- this->GeneratorTarget->GetName(), language);
+ this->LocalGenerator, config, this->GeneratorTarget, language);
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index af4b466..231cacb 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -722,8 +722,8 @@ static void PopulateFileGroupData(
? languageDataMap.at(kInterfaceSourcesLanguageDataKey)
: languageDataMap.at(fileData.Language);
cmLocalGenerator* lg = target->GetLocalGenerator();
- cmGeneratorExpressionInterpreter genexInterpreter(
- lg, target, config, target->GetName(), fileData.Language);
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
+ fileData.Language);
std::string compileFlags = ld.Flags;
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
@@ -817,7 +817,7 @@ static Json::Value DumpSourceFilesList(
auto targetProp = target->Target->GetProperty("INTERFACE_SOURCES");
if (targetProp != nullptr) {
cmGeneratorExpressionInterpreter genexInterpreter(
- target->GetLocalGenerator(), target, config, target->GetName(), "");
+ target->GetLocalGenerator(), config, target);
auto evaluatedSources = cmsys::SystemTools::SplitString(
genexInterpreter.Evaluate(targetProp, "INTERFACE_SOURCES"), ';');
@@ -977,8 +977,7 @@ static void CreateInterfaceSourcesEntry(
LanguageData& ld = languageDataMap[kInterfaceSourcesLanguageDataKey];
ld.Language = "";
- cmGeneratorExpressionInterpreter genexInterpreter(lg, target, config,
- target->GetName(), "");
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target);
std::vector<std::string> propertyValue;
GetTargetProperty(genexInterpreter, target, "INTERFACE_INCLUDE_DIRECTORIES",
propertyValue);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9e74335..53a2a59 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2117,8 +2117,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
flagtable = gg->GetCSharpFlagTable();
}
cmGeneratorExpressionInterpreter genexInterpreter(
- this->LocalGenerator, this->GeneratorTarget, config,
- this->GeneratorTarget->GetName(), lang);
+ this->LocalGenerator, config, this->GeneratorTarget, lang);
cmVS10GeneratorOptions clOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
flagtable, this);