1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-15 03:48:02 +08:00

Merge branch 'backport-3.31-custom-transitive-properties' (early part)

This commit is contained in:
Brad King
2025-02-22 09:41:13 -05:00
13 changed files with 122 additions and 82 deletions

View File

@@ -500,9 +500,10 @@ std::string cmCommonTargetGenerator::GetLinkerLauncher(
std::string propName = lang + "_LINKER_LAUNCHER";
cmValue launcherProp = this->GeneratorTarget->GetProperty(propName);
if (cmNonempty(launcherProp)) {
cmGeneratorExpressionDAGChecker dagChecker(
this->GeneratorTarget, propName, nullptr, nullptr,
this->LocalCommonGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this->GeneratorTarget, propName, nullptr, nullptr,
this->LocalCommonGenerator, config,
};
std::string evaluatedLinklauncher = cmGeneratorExpression::Evaluate(
*launcherProp, this->LocalCommonGenerator, config, this->GeneratorTarget,
&dagChecker, this->GeneratorTarget, lang);

View File

@@ -626,18 +626,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target,
if (cmValue feature = this->Target->GetProperty(key)) {
if (!feature->empty() && key.length() > lloPrefix.length()) {
auto item = key.substr(lloPrefix.length());
cmGeneratorExpressionDAGChecker dag{
cmGeneratorExpressionDAGChecker dagChecker{
this->Target->GetBacktrace(),
this->Target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
this->Target->GetLocalGenerator(),
config
config,
};
auto overrideFeature = cmGeneratorExpression::Evaluate(
*feature, this->Target->GetLocalGenerator(), config,
this->Target, &dag, this->Target, linkLanguage);
this->Target, &dagChecker, this->Target, linkLanguage);
this->LinkLibraryOverride.emplace(item, overrideFeature);
}
}
@@ -646,16 +646,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target,
// global override property
if (cmValue linkLibraryOverride =
this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) {
cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(),
target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
target->GetLocalGenerator(),
config };
cmGeneratorExpressionDAGChecker dagChecker{
target->GetBacktrace(),
target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
target->GetLocalGenerator(),
config,
};
auto overrideValue = cmGeneratorExpression::Evaluate(
*linkLibraryOverride, target->GetLocalGenerator(), config, target, &dag,
target, linkLanguage);
*linkLibraryOverride, target->GetLocalGenerator(), config, target,
&dagChecker, target, linkLanguage);
std::vector<std::string> overrideList =
cmTokenize(overrideValue, ',', cmTokenizerMode::New);

View File

@@ -86,9 +86,14 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
tgt, "LINK_OPTIONS", nullptr, nullptr, tgt->GetLocalGenerator(),
this->Config);
}
cmGeneratorExpressionDAGChecker dagChecker(
tgt, propName, nullptr, parentDagChecker.get(), tgt->GetLocalGenerator(),
this->Config);
cmGeneratorExpressionDAGChecker dagChecker{
tgt,
propName,
nullptr,
parentDagChecker.get(),
tgt->GetLocalGenerator(),
this->Config,
};
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);

View File

@@ -425,10 +425,14 @@ std::string const& cmGeneratorExpressionInterpreter::Evaluate(
this->GeneratorExpression.Parse(std::move(expression));
// Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS
cmGeneratorExpressionDAGChecker dagChecker(
cmGeneratorExpressionDAGChecker dagChecker{
this->HeadTarget,
property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr,
nullptr, this->LocalGenerator, this->Config);
property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property,
nullptr,
nullptr,
this->LocalGenerator,
this->Config,
};
return this->CompiledGeneratorExpression->Evaluate(
this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr,

View File

@@ -483,10 +483,15 @@ protected:
cmGeneratorExpressionDAGChecker* dagCheckerParent) const
{
if (context->HeadTarget) {
cmGeneratorExpressionDAGChecker dagChecker(
context->Backtrace, context->HeadTarget,
genexOperator + ":" + expression, content, dagCheckerParent,
context->LG, context->Config);
cmGeneratorExpressionDAGChecker dagChecker{
context->Backtrace,
context->HeadTarget,
genexOperator + ":" + expression,
content,
dagCheckerParent,
context->LG,
context->Config,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: {
@@ -2987,9 +2992,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
dagCheckerParent, usage));
}
cmGeneratorExpressionDAGChecker dagChecker(
context->Backtrace, target, propertyName, content, dagCheckerParent,
context->LG, context->Config);
cmGeneratorExpressionDAGChecker dagChecker{
context->Backtrace, target, propertyName, content,
dagCheckerParent, context->LG, context->Config,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:

View File

@@ -737,8 +737,9 @@ std::string cmGeneratorTarget::GetLinkerTypeProperty(
std::string propName{ "LINKER_TYPE" };
auto linkerType = this->GetProperty(propName);
if (!linkerType.IsEmpty()) {
cmGeneratorExpressionDAGChecker dagChecker(
this, propName, nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, propName, nullptr, nullptr, this->LocalGenerator, config,
};
auto ltype =
cmGeneratorExpression::Evaluate(*linkerType, this->GetLocalGenerator(),
config, this, &dagChecker, this, lang);
@@ -1198,9 +1199,10 @@ void cmGeneratorTarget::AddSystemIncludeCacheKey(
std::string const& key, std::string const& config,
std::string const& language) const
{
cmGeneratorExpressionDAGChecker dagChecker(
this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr, this->LocalGenerator,
config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr,
nullptr, this->LocalGenerator, config,
};
bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
@@ -1969,8 +1971,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
return;
}
cmGeneratorExpressionDAGChecker dagChecker(
this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config,
};
cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator,
config, this, &dagChecker),
result);

View File

@@ -46,13 +46,13 @@ std::string AddLangSpecificInterfaceIncludeDirectories(
std::string const& propertyName, IncludeDirectoryFallBack mode,
cmGeneratorExpressionDAGChecker* context)
{
cmGeneratorExpressionDAGChecker dag{
cmGeneratorExpressionDAGChecker dagChecker{
target->GetBacktrace(), target, propertyName, nullptr, context,
target->GetLocalGenerator(), config
target->GetLocalGenerator(), config,
};
switch (dag.Check()) {
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
dag.ReportError(
dagChecker.ReportError(
nullptr, "$<TARGET_PROPERTY:" + target->GetName() + ",propertyName");
CM_FALLTHROUGH;
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
@@ -99,9 +99,9 @@ void AddLangSpecificImplicitIncludeDirectories(
{
if (auto const* libraries =
target->GetLinkImplementationLibraries(config, UseTo::Compile)) {
cmGeneratorExpressionDAGChecker dag{
cmGeneratorExpressionDAGChecker dagChecker{
target->GetBacktrace(), target, propertyName, nullptr, nullptr,
target->GetLocalGenerator(), config
target->GetLocalGenerator(), config,
};
for (cmLinkImplItem const& library : libraries->Libraries) {
@@ -127,10 +127,10 @@ void AddLangSpecificImplicitIncludeDirectories(
}
}
cmExpandList(
AddLangSpecificInterfaceIncludeDirectories(
target, dependency, lang, config, propertyName, mode, &dag),
entry.Values);
cmExpandList(AddLangSpecificInterfaceIncludeDirectories(
target, dependency, lang, config, propertyName, mode,
&dagChecker),
entry.Values);
entries.Entries.emplace_back(std::move(entry));
}
}
@@ -222,9 +222,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
std::vector<BT<std::string>> includes;
std::unordered_set<std::string> uniqueIncludes;
cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "INCLUDE_DIRECTORIES", nullptr,
nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };

View File

@@ -542,8 +542,9 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
return;
}
// Keep this logic in sync with ComputeLinkImplementationLibraries.
cmGeneratorExpressionDAGChecker dagChecker(this, prop, nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, prop, nullptr, nullptr, this->LocalGenerator, config,
};
// The $<LINK_ONLY> expression may be in a link interface to specify
// private link dependencies that are otherwise excluded from usage
// requirements.
@@ -1133,8 +1134,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
// Collect libraries directly linked in this configuration.
for (auto const& entry : entryRange) {
// Keep this logic in sync with ExpandLinkItems.
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config,
};
// The $<LINK_ONLY> expression may be used to specify link dependencies
// that are otherwise excluded from usage requirements.
if (usage == UseTo::Compile) {

View File

@@ -122,8 +122,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueDirectories;
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };

View File

@@ -230,8 +230,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -269,8 +270,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueFeatures;
cmGeneratorExpressionDAGChecker dagChecker(
this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -317,9 +319,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
std::vector<BT<std::string>> list;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_DEFINITIONS", nullptr,
nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -353,9 +356,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
}
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "PRECOMPILE_HEADERS", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -410,8 +413,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -591,9 +595,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "STATIC_LIBRARY_OPTIONS",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "STATIC_LIBRARY_OPTIONS", nullptr,
nullptr, this->LocalGenerator, config,
};
EvaluatedTargetPropertyEntries entries;
if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
@@ -635,8 +640,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
{
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config,
};
EvaluatedTargetPropertyEntries entries;
if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) {

View File

@@ -240,8 +240,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
this->DebugSourcesDone = true;
cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "SOURCES", nullptr, nullptr, this->LocalGenerator, config,
};
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, std::string(), &dagChecker, this->SourceEntries);

View File

@@ -109,9 +109,15 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
// Evaluate $<TARGET_PROPERTY:this,prop> as if it were compiled. This is
// a subset of TargetPropertyNode::Evaluate without stringify/parse steps
// but sufficient for transitive interface properties.
cmGeneratorExpressionDAGChecker dagChecker(
context->Backtrace, this, prop, nullptr, dagCheckerParent,
this->LocalGenerator, context->Config);
cmGeneratorExpressionDAGChecker dagChecker{
context->Backtrace,
this,
prop,
nullptr,
dagCheckerParent,
this->LocalGenerator,
context->Config,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
dagChecker.ReportError(

View File

@@ -1920,9 +1920,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
if (this->MultiConfig) {
for (auto const& cfg : this->ConfigsList) {
if (!cfg.empty()) {
cmGeneratorExpressionDAGChecker dagChecker(
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
this->LocalGen, cfg);
cmGeneratorExpressionDAGChecker dagChecker{
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr,
nullptr, this->LocalGen, cfg,
};
AddInterfaceEntries(this->GenTarget, cfg,
"INTERFACE_AUTOMOC_MACRO_NAMES", "CXX",
&dagChecker, InterfaceAutoMocMacroNamesEntries,
@@ -1930,9 +1931,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
}
} else {
cmGeneratorExpressionDAGChecker dagChecker(
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
this->LocalGen, this->ConfigDefault);
cmGeneratorExpressionDAGChecker dagChecker{
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr,
nullptr, this->LocalGen, this->ConfigDefault,
};
AddInterfaceEntries(this->GenTarget, this->ConfigDefault,
"INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker,
InterfaceAutoMocMacroNamesEntries,