GenEx: Construct cmGeneratorExpressionDAGChecker with full evaluation context

Extend commit e8010b67c7 (cmGeneratorExpressionDAGChecker: Make local
generator available in constructor, 2024-04-25, v3.30.0-rc1~172^2~6) and
commit 633afa0b2e (cmGeneratorExpressionDAGChecker: Make config name
available in constructor, 2024-05-08, v3.30.0-rc1~82^2~2) to make the
full evaluation context available in the constructor.
This commit is contained in:
Brad King
2025-09-21 14:26:55 -04:00
parent d4d204382f
commit 1735b0d147
15 changed files with 40 additions and 74 deletions

View File

@@ -523,10 +523,9 @@ std::string cmCommonTargetGenerator::GetLinkerLauncher(
cmValue launcherProp = this->GeneratorTarget->GetProperty(propName);
if (cmNonempty(launcherProp)) {
cm::GenEx::Context context(this->LocalCommonGenerator, config, lang);
cmGeneratorExpressionDAGChecker dagChecker{
this->GeneratorTarget, propName, nullptr, nullptr, context.LG,
context.Config
};
cmGeneratorExpressionDAGChecker dagChecker{ this->GeneratorTarget,
propName, nullptr, nullptr,
context };
std::string evaluatedLinklauncher = cmGeneratorExpression::Evaluate(
*launcherProp, context.LG, context.Config, this->GeneratorTarget,
&dagChecker, this->GeneratorTarget, context.Language);

View File

@@ -630,13 +630,8 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target,
if (!feature->empty() && key.length() > lloPrefix.length()) {
auto item = key.substr(lloPrefix.length());
cmGeneratorExpressionDAGChecker dagChecker{
this->Target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
context.LG,
context.Config,
this->Target->GetBacktrace(),
this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr,
context, this->Target->GetBacktrace(),
};
auto overrideFeature = cmGeneratorExpression::Evaluate(
*feature, context.LG, context.Config, this->Target, &dagChecker,
@@ -650,13 +645,8 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target,
if (cmValue linkLibraryOverride =
this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) {
cmGeneratorExpressionDAGChecker dagChecker{
this->Target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
context.LG,
context.Config,
this->Target->GetBacktrace(),
this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr,
context, this->Target->GetBacktrace(),
};
auto overrideValue = cmGeneratorExpression::Evaluate(
*linkLibraryOverride, context.LG, context.Config, this->Target,

View File

@@ -86,10 +86,10 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
// To please constraint checks of DAGChecker, this property must have
// LINK_OPTIONS property as parent
parentDagChecker = cm::make_unique<cmGeneratorExpressionDAGChecker>(
tgt, "LINK_OPTIONS", nullptr, nullptr, context.LG, context.Config);
tgt, "LINK_OPTIONS", nullptr, nullptr, context);
}
cmGeneratorExpressionDAGChecker dagChecker{
tgt, propName, nullptr, parentDagChecker.get(), context.LG, context.Config,
tgt, propName, nullptr, parentDagChecker.get(), context,
};
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);

View File

@@ -463,8 +463,7 @@ std::string const& cmGeneratorExpressionInterpreter::Evaluate(
property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property,
nullptr,
nullptr,
context.LG,
context.Config,
context,
};
return this->CompiledGeneratorExpression->Evaluate(

View File

@@ -21,9 +21,8 @@
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
cmGeneratorTarget const* target, std::string property,
GeneratorExpressionContent const* content,
cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG,
std::string const& contextConfig, cmListFileBacktrace backtrace,
ComputingLinkLibraries computingLinkLibraries)
cmGeneratorExpressionDAGChecker* parent, cm::GenEx::Context const& context,
cmListFileBacktrace backtrace, ComputingLinkLibraries computingLinkLibraries)
: Parent(parent)
, Top(parent ? parent->Top : this)
, Target(target)
@@ -37,7 +36,8 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
} else {
this->TopIsTransitiveProperty =
this->Target
->IsTransitiveProperty(this->Property, contextLG, contextConfig, this)
->IsTransitiveProperty(this->Property, context.LG, context.Config,
this)
.has_value();
}

View File

@@ -12,13 +12,13 @@
namespace cm {
namespace GenEx {
struct Context;
struct Evaluation;
}
}
struct GeneratorExpressionContent;
class cmGeneratorTarget;
class cmLocalGenerator;
struct cmGeneratorExpressionDAGChecker
{
@@ -30,8 +30,7 @@ struct cmGeneratorExpressionDAGChecker
cmGeneratorExpressionDAGChecker(
cmGeneratorTarget const* target, std::string property,
GeneratorExpressionContent const* content,
cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG,
std::string const& contextConfig,
cmGeneratorExpressionDAGChecker* parent, cm::GenEx::Context const& context,
cmListFileBacktrace backtrace = cmListFileBacktrace(),
ComputingLinkLibraries computingLinkLibraries =
ComputingLinkLibraries::No);

View File

@@ -481,8 +481,7 @@ protected:
cmGeneratorExpressionDAGChecker dagChecker{
eval->HeadTarget, genexOperator + ":" + expression,
content, dagCheckerParent,
eval->Context.LG, eval->Context.Config,
eval->Backtrace,
eval->Context, eval->Backtrace,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
@@ -2926,9 +2925,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
}
cmGeneratorExpressionDAGChecker dagChecker{
target, propertyName, content,
dagCheckerParent, eval->Context.LG, eval->Context.Config,
eval->Backtrace,
target, propertyName, content,
dagCheckerParent, eval->Context, eval->Backtrace,
};
switch (dagChecker.Check()) {

View File

@@ -740,7 +740,7 @@ std::string cmGeneratorTarget::GetLinkerTypeProperty(
if (!linkerType.IsEmpty()) {
cm::GenEx::Context context(this->LocalGenerator, config, lang);
cmGeneratorExpressionDAGChecker dagChecker{
this, propName, nullptr, nullptr, context.LG, context.Config,
this, propName, nullptr, nullptr, context,
};
auto ltype = cmGeneratorExpression::Evaluate(
*linkerType, context.LG, context.Config, this, &dagChecker, this,
@@ -1203,8 +1203,7 @@ void cmGeneratorTarget::AddSystemIncludeCacheKey(
{
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr, context.LG,
context.Config,
this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr, context,
};
bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
@@ -1981,7 +1980,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
cm::GenEx::Context context(this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "AUTOUIC_OPTIONS", nullptr, nullptr, context.LG, context.Config,
this, "AUTOUIC_OPTIONS", nullptr, nullptr, context,
};
cmExpandList(cmGeneratorExpression::Evaluate(
prop, context.LG, context.Config, this, &dagChecker),

View File

@@ -49,13 +49,8 @@ std::string AddLangSpecificInterfaceIncludeDirectories(
{
cm::GenEx::Context context(target->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
target,
propertyName,
nullptr,
dagCheckerParent,
context.LG,
context.Config,
target->GetBacktrace(),
target, propertyName, nullptr,
dagCheckerParent, context, target->GetBacktrace(),
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
@@ -107,8 +102,7 @@ void AddLangSpecificImplicitIncludeDirectories(
target->GetLinkImplementationLibraries(config, UseTo::Compile)) {
cm::GenEx::Context context(target->LocalGenerator, config, lang);
cmGeneratorExpressionDAGChecker dagChecker{
target, propertyName, nullptr, nullptr, context.LG,
context.Config, target->GetBacktrace(),
target, propertyName, nullptr, nullptr, context, target->GetBacktrace(),
};
for (cmLinkImplItem const& library : libraries->Libraries) {
@@ -232,7 +226,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
cm::GenEx::Context context(this->LocalGenerator, config, lang);
cmGeneratorExpressionDAGChecker dagChecker{
this, "INCLUDE_DIRECTORIES", nullptr, nullptr, context.LG, context.Config,
this, "INCLUDE_DIRECTORIES", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(

View File

@@ -549,8 +549,7 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
prop,
nullptr,
nullptr,
context.LG,
context.Config,
context,
cmListFileBacktrace(),
cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes,
};
@@ -1149,8 +1148,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
"LINK_LIBRARIES",
nullptr,
nullptr,
context.LG,
context.Config,
context,
cmListFileBacktrace(),
cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes,
};

View File

@@ -124,9 +124,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
std::unordered_set<std::string> uniqueDirectories;
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_DIRECTORIES", nullptr, nullptr, context.LG, context.Config,
this, "LINK_DIRECTORIES", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(

View File

@@ -234,7 +234,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_OPTIONS", nullptr, nullptr, context.LG, context.Config,
this, "COMPILE_OPTIONS", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(
@@ -279,7 +279,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
/*language=*/std::string());
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_FEATURES", nullptr, nullptr, context.LG, context.Config,
this, "COMPILE_FEATURES", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(
@@ -331,7 +331,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_DEFINITIONS", nullptr, nullptr, context.LG, context.Config,
this, "COMPILE_DEFINITIONS", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(
@@ -371,7 +371,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "PRECOMPILE_HEADERS", nullptr, nullptr, context.LG, context.Config,
this, "PRECOMPILE_HEADERS", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(
@@ -432,7 +432,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_OPTIONS", nullptr, nullptr, context.LG, context.Config,
this, "LINK_OPTIONS", nullptr, nullptr, context,
};
cmList debugProperties{ this->Makefile->GetDefinition(
@@ -617,8 +617,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "STATIC_LIBRARY_OPTIONS", nullptr, nullptr,
context.LG, context.Config,
this, "STATIC_LIBRARY_OPTIONS", nullptr, nullptr, context,
};
EvaluatedTargetPropertyEntries entries;
@@ -663,7 +662,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
std::unordered_set<std::string> uniqueOptions;
cm::GenEx::Context context(this->LocalGenerator, config, language);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_DEPENDS", nullptr, nullptr, context.LG, context.Config,
this, "LINK_DEPENDS", nullptr, nullptr, context,
};
EvaluatedTargetPropertyEntries entries;

View File

@@ -247,7 +247,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
/*language=*/std::string());
cmGeneratorExpressionDAGChecker dagChecker{
this, "SOURCES", nullptr, nullptr, context.LG, context.Config,
this, "SOURCES", nullptr, nullptr, context,
};
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(

View File

@@ -112,13 +112,7 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
// a subset of TargetPropertyNode::Evaluate without stringify/parse steps
// but sufficient for transitive interface properties.
cmGeneratorExpressionDAGChecker dagChecker{
this,
prop,
nullptr,
dagCheckerParent,
eval->Context.LG,
eval->Context.Config,
eval->Backtrace,
this, prop, nullptr, dagCheckerParent, eval->Context, eval->Backtrace,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:

View File

@@ -1969,8 +1969,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
if (!cfg.empty()) {
cm::GenEx::Context context(this->LocalGen, cfg, "CXX");
cmGeneratorExpressionDAGChecker dagChecker{
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
context.LG, context.Config,
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, context,
};
AddInterfaceEntries(
this->GenTarget, context.Config, "INTERFACE_AUTOMOC_MACRO_NAMES",
@@ -1981,8 +1980,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
} else {
cm::GenEx::Context context(this->LocalGen, this->ConfigDefault, "CXX");
cmGeneratorExpressionDAGChecker dagChecker{
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
context.LG, context.Config,
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, context,
};
AddInterfaceEntries(this->GenTarget, context.Config,
"INTERFACE_AUTOMOC_MACRO_NAMES", context.Language,