mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 07:11:05 -06:00
cmGeneratorExpression: Remove Evaluate overload by parameter re-ordering
Simplify by re-ordering parameters of cmCompiledGeneratorExpression::Evaluate so that frequently used parameters are before less frequently used parameters. This allows with little extra arguments to get rid of one Evaluate overload, which makes it easier to implement the cmGeneratorExpression::Evaluate utility. The latter would otherwise need four overloads.
This commit is contained in:
@@ -75,7 +75,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
|
||||
cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
|
||||
|
||||
std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
|
||||
&gDummyHead, tgt, &dagChecker, language);
|
||||
&gDummyHead, &dagChecker, tgt, language);
|
||||
|
||||
const std::set<cmGeneratorTarget const*>& allTargets =
|
||||
cge->GetAllTargetsSeen();
|
||||
|
||||
@@ -40,17 +40,7 @@ const std::string& cmCompiledGeneratorExpression::Evaluate(
|
||||
cmLocalGenerator* lg, const std::string& config,
|
||||
const cmGeneratorTarget* headTarget,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
std::string const& language) const
|
||||
{
|
||||
return this->Evaluate(lg, config, headTarget, headTarget, dagChecker,
|
||||
language);
|
||||
}
|
||||
|
||||
const std::string& cmCompiledGeneratorExpression::Evaluate(
|
||||
cmLocalGenerator* lg, const std::string& config,
|
||||
const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
std::string const& language) const
|
||||
const cmGeneratorTarget* currentTarget, std::string const& language) const
|
||||
{
|
||||
cmGeneratorExpressionContext context(
|
||||
lg, config, this->Quiet, headTarget,
|
||||
@@ -391,7 +381,7 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate(
|
||||
nullptr);
|
||||
|
||||
return this->CompiledGeneratorExpression->Evaluate(
|
||||
this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker,
|
||||
this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr,
|
||||
this->Language);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,13 +90,8 @@ public:
|
||||
const std::string& Evaluate(
|
||||
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,
|
||||
cmGeneratorTarget const* headTarget,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
cmGeneratorTarget const* currentTarget = nullptr,
|
||||
std::string const& language = std::string()) const;
|
||||
|
||||
/** Get set of targets found during evaluations. */
|
||||
|
||||
@@ -45,15 +45,15 @@
|
||||
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
||||
std::string const& prop, cmLocalGenerator* lg,
|
||||
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
|
||||
cmGeneratorTarget const* currentTarget,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker)
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
cmGeneratorTarget const* currentTarget)
|
||||
{
|
||||
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, headTarget, currentTarget, dagChecker,
|
||||
cge->Evaluate(lg, context->Config, headTarget, dagChecker, currentTarget,
|
||||
context->Language);
|
||||
if (cge->GetHadContextSensitiveCondition()) {
|
||||
context->HadContextSensitiveCondition = true;
|
||||
@@ -478,13 +478,13 @@ protected:
|
||||
}
|
||||
|
||||
return this->EvaluateDependentExpression(
|
||||
expression, context->LG, context, context->HeadTarget,
|
||||
context->CurrentTarget, &dagChecker);
|
||||
expression, context->LG, context, context->HeadTarget, &dagChecker,
|
||||
context->CurrentTarget);
|
||||
}
|
||||
|
||||
return this->EvaluateDependentExpression(
|
||||
expression, context->LG, context, context->HeadTarget,
|
||||
context->CurrentTarget, dagCheckerParent);
|
||||
expression, context->LG, context, context->HeadTarget, dagCheckerParent,
|
||||
context->CurrentTarget);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1332,7 +1332,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||
|
||||
if (!interfacePropertyName.empty()) {
|
||||
result = this->EvaluateDependentExpression(result, context->LG, context,
|
||||
target, target, &dagChecker);
|
||||
target, &dagChecker, target);
|
||||
std::string linkedTargetsContent = getLinkedTargetsContent(
|
||||
target, interfacePropertyName, context, &dagChecker);
|
||||
if (!linkedTargetsContent.empty()) {
|
||||
|
||||
@@ -43,8 +43,8 @@ struct cmGeneratorExpressionNode
|
||||
static std::string EvaluateDependentExpression(
|
||||
std::string const& prop, cmLocalGenerator* lg,
|
||||
cmGeneratorExpressionContext* context, const cmGeneratorTarget* headTarget,
|
||||
const cmGeneratorTarget* currentTarget,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker);
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
const cmGeneratorTarget* currentTarget);
|
||||
|
||||
static const cmGeneratorExpressionNode* GetNode(
|
||||
const std::string& identifier);
|
||||
|
||||
@@ -112,7 +112,8 @@ public:
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
std::string const& language) const override
|
||||
{
|
||||
return this->ge->Evaluate(lg, config, headTarget, dagChecker, language);
|
||||
return this->ge->Evaluate(lg, config, headTarget, dagChecker, nullptr,
|
||||
language);
|
||||
}
|
||||
|
||||
cmListFileBacktrace GetBacktrace() const override
|
||||
@@ -709,8 +710,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
|
||||
if (const char* dirs =
|
||||
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
|
||||
cmGeneratorExpression ge;
|
||||
cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt,
|
||||
dagChecker, language),
|
||||
cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, dagChecker,
|
||||
depTgt, language),
|
||||
result);
|
||||
}
|
||||
if (!depTgt->IsImported() || excludeImported) {
|
||||
@@ -720,8 +721,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
|
||||
if (const char* dirs =
|
||||
depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
|
||||
cmGeneratorExpression ge;
|
||||
cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt,
|
||||
dagChecker, language),
|
||||
cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, dagChecker,
|
||||
depTgt, language),
|
||||
result);
|
||||
}
|
||||
}
|
||||
@@ -1093,7 +1094,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(
|
||||
for (std::string const& it : this->Target->GetSystemIncludeDirectories()) {
|
||||
cmGeneratorExpression ge;
|
||||
cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, this,
|
||||
&dagChecker, language),
|
||||
&dagChecker, nullptr, language),
|
||||
result);
|
||||
}
|
||||
|
||||
@@ -1199,7 +1200,7 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
|
||||
|
||||
if (const char* p = this->GetProperty(prop)) {
|
||||
result = cmGeneratorExpressionNode::EvaluateDependentExpression(
|
||||
p, context->LG, context, headTarget, this, &dagChecker);
|
||||
p, context->LG, context, headTarget, &dagChecker, this);
|
||||
}
|
||||
|
||||
if (cmLinkInterfaceLibraries const* iface =
|
||||
@@ -5287,7 +5288,7 @@ void cmGeneratorTarget::ExpandLinkItems(
|
||||
std::vector<std::string> libs;
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||
cmExpandList(
|
||||
cge->Evaluate(this->LocalGenerator, config, headTarget, this, &dagChecker),
|
||||
cge->Evaluate(this->LocalGenerator, config, headTarget, &dagChecker, this),
|
||||
libs);
|
||||
this->LookupLinkItems(libs, cge->GetBacktrace(), items);
|
||||
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
|
||||
|
||||
Reference in New Issue
Block a user