summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Eiband <daniel.eiband@brainlab.com>2019-09-21 21:39:48 (GMT)
committerDaniel Eiband <daniel.eiband@brainlab.com>2019-09-22 07:49:41 (GMT)
commit1811411fecf3d9769ad7a13f6ecd01c5351df9c4 (patch)
tree13b7d923cac709aefd3bcf1cf999ccddeebd0a40
parentedb0bbd18b5c3dac16ab7d219f787513203529e4 (diff)
downloadCMake-1811411fecf3d9769ad7a13f6ecd01c5351df9c4.zip
CMake-1811411fecf3d9769ad7a13f6ecd01c5351df9c4.tar.gz
CMake-1811411fecf3d9769ad7a13f6ecd01c5351df9c4.tar.bz2
cmGeneratorExpression: Move quiet flag to cmCompiledGeneratorExpression
The quiet flag is false for all but one call to Evaluate. Make the quiet flag a setter of cmCompiledGeneratorExpression to be able to remove it from the Evaluate function signature.
-rw-r--r--Source/cmExportFileGenerator.cxx2
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx5
-rw-r--r--Source/cmGeneratorExpression.cxx36
-rw-r--r--Source/cmGeneratorExpression.h25
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx14
-rw-r--r--Source/cmGeneratorExpressionNode.cxx5
-rw-r--r--Source/cmGeneratorTarget.cxx34
-rw-r--r--Source/cmLocalGenerator.cxx3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx2
10 files changed, 68 insertions, 60 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index f9a28cd..e142560 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -380,7 +380,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
this->ReplaceInstallPrefix(dirs);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
std::string exportDirs =
- cge->Evaluate(target->GetLocalGenerator(), "", false, target);
+ cge->Evaluate(target->GetLocalGenerator(), "", target);
if (cge->GetHadContextSensitiveCondition()) {
cmLocalGenerator* lg = target->GetLocalGenerator();
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 5631d60..5852360 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -74,9 +74,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
- std::string result =
- cge->Evaluate(tgt->GetLocalGenerator(), this->Config, false, &gDummyHead,
- tgt, &dagChecker, language);
+ std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
+ &gDummyHead, tgt, &dagChecker, language);
const std::set<cmGeneratorTarget const*>& allTargets =
cge->GetAllTargetsSeen();
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index f49ed2c..9472d9a 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -21,40 +21,41 @@ cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace)
{
}
+cmGeneratorExpression::~cmGeneratorExpression() = default;
+
std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
- std::string const& input)
+ std::string input) const
{
return std::unique_ptr<cmCompiledGeneratorExpression>(
- new cmCompiledGeneratorExpression(this->Backtrace, input));
+ new cmCompiledGeneratorExpression(this->Backtrace, std::move(input)));
}
std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
- const char* input)
+ const char* input) const
{
return this->Parse(std::string(input ? input : ""));
}
-cmGeneratorExpression::~cmGeneratorExpression() = default;
-
const std::string& cmCompiledGeneratorExpression::Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet,
+ cmLocalGenerator* lg, const std::string& config,
const cmGeneratorTarget* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
std::string const& language) const
{
- return this->Evaluate(lg, config, quiet, headTarget, headTarget, dagChecker,
+ return this->Evaluate(lg, config, headTarget, headTarget, dagChecker,
language);
}
const std::string& cmCompiledGeneratorExpression::Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet,
+ cmLocalGenerator* lg, const std::string& config,
const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
std::string const& language) const
{
cmGeneratorExpressionContext context(
- lg, config, quiet, headTarget, currentTarget ? currentTarget : headTarget,
- this->EvaluateForBuildsystem, this->Backtrace, language);
+ lg, config, this->Quiet, headTarget,
+ currentTarget ? currentTarget : headTarget, this->EvaluateForBuildsystem,
+ this->Backtrace, language);
return this->EvaluateWithContext(context, dagChecker);
}
@@ -97,9 +98,10 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
cmListFileBacktrace backtrace, std::string input)
: Backtrace(std::move(backtrace))
, Input(std::move(input))
+ , EvaluateForBuildsystem(false)
+ , Quiet(false)
, HadContextSensitiveCondition(false)
, HadHeadSensitiveCondition(false)
- , EvaluateForBuildsystem(false)
{
cmGeneratorExpressionLexer l;
std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(this->Input);
@@ -377,10 +379,10 @@ void cmCompiledGeneratorExpression::GetMaxLanguageStandard(
}
const std::string& cmGeneratorExpressionInterpreter::Evaluate(
- const char* expression, const std::string& property)
+ std::string expression, const std::string& property)
{
this->CompiledGeneratorExpression =
- this->GeneratorExpression.Parse(expression);
+ this->GeneratorExpression.Parse(std::move(expression));
// Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS
cmGeneratorExpressionDAGChecker dagChecker(
@@ -389,6 +391,12 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate(
nullptr);
return this->CompiledGeneratorExpression->Evaluate(
- this->LocalGenerator, this->Config, false, this->HeadTarget, &dagChecker,
+ this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker,
this->Language);
}
+
+const std::string& cmGeneratorExpressionInterpreter::Evaluate(
+ const char* expression, const std::string& property)
+{
+ return this->Evaluate(std::string(expression ? expression : ""), property);
+}
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index ef76651..7ed024a 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -41,8 +41,9 @@ public:
cmGeneratorExpression& operator=(cmGeneratorExpression const&) = delete;
std::unique_ptr<cmCompiledGeneratorExpression> Parse(
- std::string const& input);
- std::unique_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
+ std::string input) const;
+ std::unique_ptr<cmCompiledGeneratorExpression> Parse(
+ const char* input) const;
enum PreprocessContext
{
@@ -87,13 +88,13 @@ public:
cmCompiledGeneratorExpression const&) = delete;
const std::string& Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet = false,
+ cmLocalGenerator* lg, const std::string& config,
cmGeneratorTarget const* headTarget = nullptr,
cmGeneratorTarget const* currentTarget = nullptr,
cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
std::string const& language = std::string()) const;
const std::string& Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet,
+ cmLocalGenerator* lg, const std::string& config,
cmGeneratorTarget const* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
std::string const& language = std::string()) const;
@@ -135,6 +136,8 @@ public:
this->EvaluateForBuildsystem = eval;
}
+ void SetQuiet(bool quiet) { this->Quiet = quiet; }
+
void GetMaxLanguageStandard(cmGeneratorTarget const* tgt,
std::map<std::string, std::string>& mapping);
@@ -152,6 +155,8 @@ private:
std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
const std::string Input;
bool NeedsEvaluation;
+ bool EvaluateForBuildsystem;
+ bool Quiet;
mutable std::set<cmGeneratorTarget*> DependTargets;
mutable std::set<cmGeneratorTarget const*> AllTargetsSeen;
@@ -163,7 +168,6 @@ private:
mutable bool HadContextSensitiveCondition;
mutable bool HadHeadSensitiveCondition;
mutable std::set<cmGeneratorTarget const*> SourceSensitiveTargets;
- bool EvaluateForBuildsystem;
};
class cmGeneratorExpressionInterpreter
@@ -172,11 +176,11 @@ public:
cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator,
std::string config,
cmGeneratorTarget const* headTarget,
- std::string lang = std::string())
+ std::string language = std::string())
: LocalGenerator(localGenerator)
, Config(std::move(config))
, HeadTarget(headTarget)
- , Language(std::move(lang))
+ , Language(std::move(language))
{
}
@@ -185,13 +189,10 @@ public:
cmGeneratorExpressionInterpreter& operator=(
cmGeneratorExpressionInterpreter const&) = delete;
+ const std::string& Evaluate(std::string expression,
+ const std::string& property);
const std::string& Evaluate(const char* expression,
const std::string& property);
- const std::string& Evaluate(const std::string& expression,
- const std::string& property)
- {
- return this->Evaluate(expression.c_str(), property);
- }
protected:
cmGeneratorExpression GeneratorExpression;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index eb43270..aa2c1a6 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -37,8 +37,8 @@ void cmGeneratorExpressionEvaluationFile::Generate(
{
std::string rawCondition = this->Condition->GetInput();
if (!rawCondition.empty()) {
- std::string condResult = this->Condition->Evaluate(
- lg, config, false, nullptr, nullptr, nullptr, lang);
+ std::string condResult =
+ this->Condition->Evaluate(lg, config, nullptr, nullptr, nullptr, lang);
if (condResult == "0") {
return;
}
@@ -54,9 +54,9 @@ void cmGeneratorExpressionEvaluationFile::Generate(
}
std::string outputFileName = this->OutputFileExpr->Evaluate(
- lg, config, false, nullptr, nullptr, nullptr, lang);
- const std::string& outputContent = inputExpression->Evaluate(
- lg, config, false, nullptr, nullptr, nullptr, lang);
+ lg, config, nullptr, nullptr, nullptr, lang);
+ const std::string& outputContent =
+ inputExpression->Evaluate(lg, config, nullptr, nullptr, nullptr, lang);
if (cmSystemTools::FileIsFullPath(outputFileName)) {
outputFileName = cmSystemTools::CollapseFullPath(outputFileName);
@@ -100,8 +100,8 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
gg->GetEnabledLanguages(enabledLanguages);
for (std::string const& le : enabledLanguages) {
- std::string name = this->OutputFileExpr->Evaluate(
- lg, config, false, nullptr, nullptr, nullptr, le);
+ std::string name = this->OutputFileExpr->Evaluate(lg, config, nullptr,
+ nullptr, nullptr, le);
cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(
name, false, cmSourceFileLocationKind::Known);
// Tell TraceDependencies that the file is not expected to exist
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index d524867..419a82c 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -51,9 +51,10 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
cmGeneratorExpression ge(context->Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
+ cge->SetQuiet(context->Quiet);
std::string result =
- cge->Evaluate(lg, context->Config, context->Quiet, headTarget,
- currentTarget, dagChecker, context->Language);
+ cge->Evaluate(lg, context->Config, headTarget, currentTarget, dagChecker,
+ context->Language);
if (cge->GetHadContextSensitiveCondition()) {
context->HadContextSensitiveCondition = true;
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 372b83d..454bcbc 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -112,8 +112,7 @@ public:
cmGeneratorExpressionDAGChecker* dagChecker,
std::string const& language) const override
{
- return this->ge->Evaluate(lg, config, false, headTarget, dagChecker,
- language);
+ return this->ge->Evaluate(lg, config, headTarget, dagChecker, language);
}
cmListFileBacktrace GetBacktrace() const override
@@ -710,8 +709,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
if (const char* dirs =
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
cmGeneratorExpression ge;
- cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, false, headTarget,
- depTgt, dagChecker, language),
+ cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt,
+ dagChecker, language),
result);
}
if (!depTgt->IsImported() || excludeImported) {
@@ -721,8 +720,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
if (const char* dirs =
depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
cmGeneratorExpression ge;
- cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, false, headTarget,
- depTgt, dagChecker, language),
+ cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt,
+ dagChecker, language),
result);
}
}
@@ -1093,8 +1092,8 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(
std::vector<std::string> result;
for (std::string const& it : this->Target->GetSystemIncludeDirectories()) {
cmGeneratorExpression ge;
- cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, false,
- this, &dagChecker, language),
+ cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, this,
+ &dagChecker, language),
result);
}
@@ -1290,7 +1289,7 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget,
EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
cmExpandList(cge->Evaluate(headTarget->GetLocalGenerator(), config,
- false, headTarget, dagChecker),
+ headTarget, dagChecker),
ee.Values);
if (cge->GetHadContextSensitiveCondition()) {
ee.ContextDependent = true;
@@ -2519,9 +2518,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
cmGeneratorExpressionDAGChecker dagChecker(this, "AUTOUIC_OPTIONS", nullptr,
nullptr);
- cmExpandList(ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false,
- this, &dagChecker),
- result);
+ cmExpandList(
+ ge.Parse(prop)->Evaluate(this->LocalGenerator, config, this, &dagChecker),
+ result);
}
void processILibs(const std::string& config,
@@ -2790,7 +2789,8 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Check for target references in generator expressions.
for (std::string const& cl : cCmdLine) {
const std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
- cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
+ cge->SetQuiet(true);
+ cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "");
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
targets.insert(geTargets.begin(), geTargets.end());
}
@@ -5286,9 +5286,9 @@ void cmGeneratorTarget::ExpandLinkItems(
}
std::vector<std::string> libs;
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
- cmExpandList(cge->Evaluate(this->LocalGenerator, config, false, headTarget,
- this, &dagChecker),
- libs);
+ cmExpandList(
+ cge->Evaluate(this->LocalGenerator, config, headTarget, this, &dagChecker),
+ libs);
this->LookupLinkItems(libs, cge->GetBacktrace(), items);
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
}
@@ -6358,7 +6358,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
cmGeneratorExpression ge(*btIt);
std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
std::string const& evaluated =
- cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
+ cge->Evaluate(this->LocalGenerator, config, head, &dagChecker);
cmExpandList(evaluated, llibs);
if (cge->GetHadHeadSensitiveCondition()) {
impl.HadHeadSensitiveCondition = true;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e059548..19962e3 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1713,8 +1713,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(msvcRuntimeLibraryValue);
- std::string const msvcRuntimeLibrary =
- cge->Evaluate(this, config, false, target);
+ std::string const msvcRuntimeLibrary = cge->Evaluate(this, config, target);
if (!msvcRuntimeLibrary.empty()) {
if (const char* msvcRuntimeLibraryOptions =
this->Makefile->GetDefinition(
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 482af22..fa361bb 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -156,7 +156,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
std::vector<std::string> files;
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop_value);
- cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName, false,
+ cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName,
this->GeneratorTarget, nullptr, nullptr),
files);
return files;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 2ab5adf..bee044e 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1322,7 +1322,7 @@ void cmNinjaTargetGenerator::AdditionalCleanFiles()
auto cge = ge.Parse(prop_value);
cmExpandList(cge->Evaluate(
lg, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"),
- false, this->GeneratorTarget, nullptr, nullptr),
+ this->GeneratorTarget, nullptr, nullptr),
cleanFiles);
}
std::string const& binaryDir = lg->GetCurrentBinaryDirectory();