From 82151ea2891a89734a4c5dc28a4e861ba2d7000b Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 22 Feb 2025 07:22:58 -0500 Subject: cmGeneratorExpressionDAGChecker: Construct with initializer list syntax --- Source/cmCommonTargetGenerator.cxx | 7 +++-- Source/cmComputeLinkDepends.cxx | 26 ++++++++-------- Source/cmExportTryCompileFileGenerator.cxx | 11 +++++-- Source/cmGeneratorExpression.cxx | 10 +++++-- Source/cmGeneratorExpressionNode.cxx | 20 ++++++++----- Source/cmGeneratorTarget.cxx | 17 ++++++----- Source/cmGeneratorTarget_IncludeDirectories.cxx | 27 +++++++++-------- Source/cmGeneratorTarget_Link.cxx | 10 ++++--- Source/cmGeneratorTarget_LinkDirectories.cxx | 5 ++-- Source/cmGeneratorTarget_Options.cxx | 40 ++++++++++++++----------- Source/cmGeneratorTarget_Sources.cxx | 5 ++-- Source/cmGeneratorTarget_TransitiveProperty.cxx | 12 ++++++-- Source/cmQtAutoGenInitializer.cxx | 14 +++++---- 13 files changed, 122 insertions(+), 82 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 9f25904..d183dc2 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -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); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 1937674..060c4e9 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -583,18 +583,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* 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); } } @@ -603,16 +603,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* 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); auto overrideList = cmTokenize(overrideValue, ","_s); if (overrideList.size() >= 2) { diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 7ce5cd9..9190dd8 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -79,9 +79,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 cge = ge.Parse(*prop); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 8e590fa..0393079 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -422,10 +422,14 @@ const std::string& 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, diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 84521ca..c18a388 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -485,10 +485,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: diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 727d452..1c7dc0b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -711,8 +711,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); @@ -1176,9 +1177,10 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( auto iter = this->SystemIncludesCache.find(key); if (iter == this->SystemIncludesCache.end()) { - 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"); @@ -1938,8 +1940,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector& 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); diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index 6db467f..4bcb2c7 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -47,13 +47,13 @@ std::string AddLangSpecificInterfaceIncludeDirectories( const std::string& 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, "$GetName() + ",propertyName"); CM_FALLTHROUGH; case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: @@ -100,9 +100,9 @@ void AddLangSpecificImplicitIncludeDirectories( { if (const auto* libraries = target->GetLinkImplementationLibraries(config, UseTo::Compile)) { - cmGeneratorExpressionDAGChecker dag{ + cmGeneratorExpressionDAGChecker dagChecker{ target->GetBacktrace(), target, propertyName, nullptr, nullptr, - target->GetLocalGenerator(), config + target->GetLocalGenerator(), config, }; for (const cmLinkImplItem& library : libraries->Libraries) { @@ -128,10 +128,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)); } } @@ -257,9 +257,10 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( std::vector> includes; std::unordered_set 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") }; diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index 50bcefa..e1db657 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -564,8 +564,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 $ expression may be in a link interface to specify // private link dependencies that are otherwise excluded from usage // requirements. @@ -1320,8 +1321,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 $ expression may be used to specify link dependencies // that are otherwise excluded from usage requirements. if (usage == UseTo::Compile) { diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index bd89497..3acb2cb 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -125,8 +125,9 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( std::vector> result; std::unordered_set 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") }; diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index f77ef72..742b880 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -217,8 +217,9 @@ std::vector> cmGeneratorTarget::GetCompileOptions( std::vector> result; std::unordered_set 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") }; @@ -258,8 +259,9 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( std::vector> result; std::unordered_set 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") }; @@ -308,9 +310,10 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( std::vector> list; std::unordered_set 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") }; @@ -373,9 +376,9 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( } std::unordered_set 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") }; @@ -432,8 +435,9 @@ std::vector> cmGeneratorTarget::GetLinkOptions( std::vector> result; std::unordered_set 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") }; @@ -601,9 +605,10 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( std::vector> result; std::unordered_set 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")) { @@ -634,8 +639,9 @@ std::vector> cmGeneratorTarget::GetLinkDepends( { std::vector> result; std::unordered_set 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")) { diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index 94e8897..2540d81 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -264,8 +264,9 @@ std::vector> 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); diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index ac929eb..d88a5b5 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -109,9 +109,15 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( // Evaluate $ 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( diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index ee53a8e..c810c38 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1923,9 +1923,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, @@ -1933,9 +1934,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, -- cgit v0.12 From 99fee5720d46b7cfa2546c09d509e0d4e3faec02 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 22 Feb 2025 07:27:18 -0500 Subject: cmGeneratorExpressionDAGChecker: De-duplicate constructor signature --- Source/cmComputeLinkDepends.cxx | 4 ++-- Source/cmGeneratorExpressionDAGChecker.cxx | 15 ++------------- Source/cmGeneratorExpressionDAGChecker.h | 19 ++++++------------- Source/cmGeneratorExpressionNode.cxx | 11 ++++++++--- Source/cmGeneratorTarget_IncludeDirectories.cxx | 18 ++++++++++++++---- Source/cmGeneratorTarget_TransitiveProperty.cxx | 2 +- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 060c4e9..492d877 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -584,13 +584,13 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, if (!feature->empty() && key.length() > lloPrefix.length()) { auto item = key.substr(lloPrefix.length()); cmGeneratorExpressionDAGChecker dagChecker{ - this->Target->GetBacktrace(), this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, this->Target->GetLocalGenerator(), config, + this->Target->GetBacktrace(), }; auto overrideFeature = cmGeneratorExpression::Evaluate( *feature, this->Target->GetLocalGenerator(), config, @@ -604,13 +604,13 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, if (cmValue linkLibraryOverride = this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) { cmGeneratorExpressionDAGChecker dagChecker{ - target->GetBacktrace(), target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, target->GetLocalGenerator(), config, + target->GetBacktrace(), }; auto overrideValue = cmGeneratorExpression::Evaluate( *linkLibraryOverride, target->GetLocalGenerator(), config, target, diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index aad25f0..8e28b42 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -19,20 +19,9 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( cmGeneratorTarget const* target, std::string property, - const GeneratorExpressionContent* content, + GeneratorExpressionContent const* content, cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG, - std::string const& contextConfig) - : cmGeneratorExpressionDAGChecker(cmListFileBacktrace(), target, - std::move(property), content, parent, - contextLG, contextConfig) -{ -} - -cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( - cmListFileBacktrace backtrace, cmGeneratorTarget const* target, - std::string property, const GeneratorExpressionContent* content, - cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG, - std::string const& contextConfig) + std::string const& contextConfig, cmListFileBacktrace backtrace) : Parent(parent) , Top(parent ? parent->Top : this) , Target(target) diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 8b0eea7..5b4e6d6 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -17,19 +17,12 @@ class cmLocalGenerator; struct cmGeneratorExpressionDAGChecker { - cmGeneratorExpressionDAGChecker(cmListFileBacktrace backtrace, - cmGeneratorTarget const* target, - std::string property, - const GeneratorExpressionContent* content, - cmGeneratorExpressionDAGChecker* parent, - cmLocalGenerator const* contextLG, - std::string const& contextConfig); - cmGeneratorExpressionDAGChecker(cmGeneratorTarget const* target, - std::string property, - const GeneratorExpressionContent* content, - cmGeneratorExpressionDAGChecker* parent, - cmLocalGenerator const* contextLG, - std::string const& contextConfig); + cmGeneratorExpressionDAGChecker( + cmGeneratorTarget const* target, std::string property, + GeneratorExpressionContent const* content, + cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG, + std::string const& contextConfig, + cmListFileBacktrace backtrace = cmListFileBacktrace()); enum Result { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c18a388..8bd263d 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -486,13 +486,13 @@ protected: { if (context->HeadTarget) { cmGeneratorExpressionDAGChecker dagChecker{ - context->Backtrace, context->HeadTarget, genexOperator + ":" + expression, content, dagCheckerParent, context->LG, context->Config, + context->Backtrace, }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: @@ -2993,8 +2993,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } cmGeneratorExpressionDAGChecker dagChecker{ - context->Backtrace, target, propertyName, content, - dagCheckerParent, context->LG, context->Config, + target, + propertyName, + content, + dagCheckerParent, + context->LG, + context->Config, + context->Backtrace, }; switch (dagChecker.Check()) { diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index 4bcb2c7..571211d 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -48,8 +48,13 @@ std::string AddLangSpecificInterfaceIncludeDirectories( cmGeneratorExpressionDAGChecker* context) { cmGeneratorExpressionDAGChecker dagChecker{ - target->GetBacktrace(), target, propertyName, nullptr, context, - target->GetLocalGenerator(), config, + target, + propertyName, + nullptr, + context, + target->GetLocalGenerator(), + config, + target->GetBacktrace(), }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: @@ -101,8 +106,13 @@ void AddLangSpecificImplicitIncludeDirectories( if (const auto* libraries = target->GetLinkImplementationLibraries(config, UseTo::Compile)) { cmGeneratorExpressionDAGChecker dagChecker{ - target->GetBacktrace(), target, propertyName, nullptr, nullptr, - target->GetLocalGenerator(), config, + target, + propertyName, + nullptr, + nullptr, + target->GetLocalGenerator(), + config, + target->GetBacktrace(), }; for (const cmLinkImplItem& library : libraries->Libraries) { diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index d88a5b5..8c5d9bd 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -110,13 +110,13 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( // 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, + context->Backtrace, }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: -- cgit v0.12 From d7f1a100d92a772e12b3c0daee77e91d4bb35c9a Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 23 Feb 2025 08:25:32 -0500 Subject: Tests: Split CustomTransitiveProperties argument checks into helper --- Tests/CustomTransitiveProperties/CMakeLists.txt | 2 ++ Tests/CustomTransitiveProperties/check-args.c | 16 ++++++++++++++++ Tests/CustomTransitiveProperties/main.c | 21 ++------------------- 3 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 Tests/CustomTransitiveProperties/check-args.c diff --git a/Tests/CustomTransitiveProperties/CMakeLists.txt b/Tests/CustomTransitiveProperties/CMakeLists.txt index 83ceff5..8c276e9 100644 --- a/Tests/CustomTransitiveProperties/CMakeLists.txt +++ b/Tests/CustomTransitiveProperties/CMakeLists.txt @@ -91,6 +91,7 @@ target_compile_definitions(CustomTransitiveProperties PRIVATE ) # Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements. +add_executable(check-args check-args.c) set(out "${CMAKE_CURRENT_BINARY_DIR}/out-$.txt") file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced: iface1 CUSTOM_A: '$' @@ -129,6 +130,7 @@ main INTERFACE_CUSTOM_W: '$ -Dout=${out} -P${CMAKE_CURRENT_SOURCE_DIR}/check.cmake COMMAND CustomTransitiveProperties + COMMAND check-args "$" "CUSTOM_A_STATIC1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_STATIC1" "$" "CUSTOM_B_STATIC1;CUSTOM_B_IFACE1" "$" "CUSTOM_U_STATIC1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1" diff --git a/Tests/CustomTransitiveProperties/check-args.c b/Tests/CustomTransitiveProperties/check-args.c new file mode 100644 index 0000000..da97f8a --- /dev/null +++ b/Tests/CustomTransitiveProperties/check-args.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char** argv) +{ + int result = 0; + int i; + for (i = 2; i < argc; i += 2) { + if (strcmp(argv[i - 1], argv[i]) != 0) { + fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, argv[i], + argv[i - 1]); + result = 1; + } + } + return result; +} diff --git a/Tests/CustomTransitiveProperties/main.c b/Tests/CustomTransitiveProperties/main.c index ab70eb0..03325a0 100644 --- a/Tests/CustomTransitiveProperties/main.c +++ b/Tests/CustomTransitiveProperties/main.c @@ -1,6 +1,3 @@ -#include -#include - #ifdef CUSTOM_A_IFACE1 # error "CUSTOM_A_IFACE1 incorrectly defined" #endif @@ -117,21 +114,7 @@ extern int static1(void); extern int object1(void); -int check_args(int argc, char** argv) -{ - int result = 0; - int i; - for (i = 2; i < argc; i += 2) { - if (strcmp(argv[i - 1], argv[i]) != 0) { - fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, argv[i], - argv[i - 1]); - result = 1; - } - } - return result; -} - -int main(int argc, char** argv) +int main(void) { - return static1() + object1() + check_args(argc, argv); + return static1() + object1(); } -- cgit v0.12 From ff2004d43010926d4084abc1743ebaa1f39ad0b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2025 20:45:13 -0500 Subject: Tests: Extend CustomTransitiveProperties with non-transitive LINK_LIBRARIES --- Tests/CustomTransitiveProperties/CMakeLists.txt | 25 ++++++++++++++++++++++++- Tests/CustomTransitiveProperties/check.cmake | 9 +++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Tests/CustomTransitiveProperties/CMakeLists.txt b/Tests/CustomTransitiveProperties/CMakeLists.txt index 8c276e9..4d2a0aa 100644 --- a/Tests/CustomTransitiveProperties/CMakeLists.txt +++ b/Tests/CustomTransitiveProperties/CMakeLists.txt @@ -93,7 +93,7 @@ target_compile_definitions(CustomTransitiveProperties PRIVATE # Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements. add_executable(check-args check-args.c) set(out "${CMAKE_CURRENT_BINARY_DIR}/out-$.txt") -file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced: +set(in_CUSTOM [====[ iface1 CUSTOM_A: '$' iface1 INTERFACE_CUSTOM_A: '$' iface2 CUSTOM_A: '$' @@ -126,6 +126,20 @@ main CUSTOM_V: '$' main INTERFACE_CUSTOM_V: '$' main CUSTOM_W: '$' main INTERFACE_CUSTOM_W: '$' +]====]) +set(in_LINK_LIBRARIES [====[ +iface1 LINK_LIBRARIES: '$' +iface1 INTERFACE_LINK_LIBRARIES: '$' +iface2 LINK_LIBRARIES: '$' +iface2 INTERFACE_LINK_LIBRARIES: '$' +static1 LINK_LIBRARIES: '$' +static1 INTERFACE_LINK_LIBRARIES: '$' +main LINK_LIBRARIES: '$' +main INTERFACE_LINK_LIBRARIES: '$' +]====]) +file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced: +${in_CUSTOM} +${in_LINK_LIBRARIES} ") add_custom_target(check ALL VERBATIM COMMAND ${CMAKE_COMMAND} -Dconfig=$ -Dout=${out} -P${CMAKE_CURRENT_SOURCE_DIR}/check.cmake @@ -145,4 +159,13 @@ add_custom_target(check ALL VERBATIM "$" "CUSTOM_U_MAIN;CUSTOM_U_STATIC1_IFACE;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_EXECUTABLE;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_CUSTOMTRANSITIVEPROPERTIES;CUSTOM_U_OBJECT1_IFACE" "$" "CUSTOM_V_MAIN;CUSTOM_V_STATIC1_IFACE;CUSTOM_V_IFACE1" "$" "CUSTOM_W_MAIN;CUSTOM_W_IFACE1;CUSTOM_W_OBJECT1_IFACE" + COMMAND check-args + "$" "" + "$" "" + "$" "" + "$" "iface1" + "$" "iface2" + "$" "$" + "$" "static1;object1" + "$" "" ) diff --git a/Tests/CustomTransitiveProperties/check.cmake b/Tests/CustomTransitiveProperties/check.cmake index d7130c8..9d4408c 100644 --- a/Tests/CustomTransitiveProperties/check.cmake +++ b/Tests/CustomTransitiveProperties/check.cmake @@ -32,6 +32,15 @@ main CUSTOM_V: 'CUSTOM_V_MAIN;CUSTOM_V_STATIC1_IFACE;CUSTOM_V_IFACE1' main INTERFACE_CUSTOM_V: '' main CUSTOM_W: 'CUSTOM_W_MAIN;CUSTOM_W_IFACE1;CUSTOM_W_OBJECT1_IFACE' main INTERFACE_CUSTOM_W: '' + +iface1 LINK_LIBRARIES: '' +iface1 INTERFACE_LINK_LIBRARIES: '' +iface2 LINK_LIBRARIES: '' +iface2 INTERFACE_LINK_LIBRARIES: 'iface1' +static1 LINK_LIBRARIES: 'iface2' +static1 INTERFACE_LINK_LIBRARIES: '\$' +main LINK_LIBRARIES: 'static1;object1' +main INTERFACE_LINK_LIBRARIES: '' ]]) string(REGEX REPLACE "\r\n" "\n" expect "${expect}") string(REGEX REPLACE "\n+$" "" expect "${expect}") -- cgit v0.12 From 419c19d531846032774bdced93bdd8400f3a56ff Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2025 21:44:11 -0500 Subject: Tests: Extend CustomTransitiveProperties with custom transitive LINK_LIBRARIES Demonstrate presence of extra entries due to not always avoiding repeat visits. --- Tests/CustomTransitiveProperties/CMakeLists.txt | 44 +++++++++++++++++++++++++ Tests/CustomTransitiveProperties/check.cmake | 10 ++++++ Tests/CustomTransitiveProperties/main10.c | 7 ++++ Tests/CustomTransitiveProperties/static10.c | 4 +++ Tests/CustomTransitiveProperties/static11.c | 4 +++ 5 files changed, 69 insertions(+) create mode 100644 Tests/CustomTransitiveProperties/main10.c create mode 100644 Tests/CustomTransitiveProperties/static10.c create mode 100644 Tests/CustomTransitiveProperties/static11.c diff --git a/Tests/CustomTransitiveProperties/CMakeLists.txt b/Tests/CustomTransitiveProperties/CMakeLists.txt index 4d2a0aa..128687f 100644 --- a/Tests/CustomTransitiveProperties/CMakeLists.txt +++ b/Tests/CustomTransitiveProperties/CMakeLists.txt @@ -90,6 +90,18 @@ target_compile_definitions(CustomTransitiveProperties PRIVATE $ ) +# Test TRANSITIVE_LINK_PROPERTIES containing LINK_LIBRARIES itself. +add_library(iface10 INTERFACE) +set_property(TARGET iface10 PROPERTY TRANSITIVE_LINK_PROPERTIES "LINK_LIBRARIES") +add_library(iface11 INTERFACE) +target_link_libraries(iface11 INTERFACE iface10) +add_library(static10 STATIC static10.c) +target_link_libraries(static10 PRIVATE iface11) +add_library(static11 STATIC static11.c) +target_link_libraries(static11 PRIVATE static10 iface11) +add_executable(main10 main10.c) +target_link_libraries(main10 PRIVATE static11 static10) + # Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements. add_executable(check-args check-args.c) set(out "${CMAKE_CURRENT_BINARY_DIR}/out-$.txt") @@ -136,6 +148,16 @@ static1 LINK_LIBRARIES: '$' static1 INTERFACE_LINK_LIBRARIES: '$' main LINK_LIBRARIES: '$' main INTERFACE_LINK_LIBRARIES: '$' +iface10 LINK_LIBRARIES: '$' +iface10 INTERFACE_LINK_LIBRARIES: '$' +iface11 LINK_LIBRARIES: '$' +iface11 INTERFACE_LINK_LIBRARIES: '$' +static10 LINK_LIBRARIES: '$' +static10 INTERFACE_LINK_LIBRARIES: '$' +static11 LINK_LIBRARIES: '$' +static11 INTERFACE_LINK_LIBRARIES: '$' +main10 LINK_LIBRARIES: '$' +main10 INTERFACE_LINK_LIBRARIES: '$' ]====]) file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced: ${in_CUSTOM} @@ -168,4 +190,26 @@ add_custom_target(check ALL VERBATIM "$" "$" "$" "static1;object1" "$" "" + COMMAND check-args + "$" "" + "$" "" + "$" "" + "$" "iface10" + "$" "iface11;iface10" + # _/ \__ + # / \ + # "static10[iface11];iface11[iface10]" + "$" "iface11;iface10" + "$" "static10;iface11;iface11;iface10;iface10" + # / / \ \ \___ extra! + # __/ __/ \__ \__________ + # / / \ \ + # "static11[static10;iface11];static10[iface11;iface11[iface10]]" + "$" "static10;iface11;iface11;iface10;iface10" + "$" "static11;static10;static10;iface11;iface11;iface10;iface10;iface11;iface10" + # / / | | \ \ \_______\_______\____ extra! + # _______/ _______/ | | \______ \______________ + # / / | | \ \ + # "main10[static11;static10];static11[static10;iface11;static10[iface11;iface11[iface10]]]" + "$" "" ) diff --git a/Tests/CustomTransitiveProperties/check.cmake b/Tests/CustomTransitiveProperties/check.cmake index 9d4408c..31a5c9f 100644 --- a/Tests/CustomTransitiveProperties/check.cmake +++ b/Tests/CustomTransitiveProperties/check.cmake @@ -41,6 +41,16 @@ static1 LINK_LIBRARIES: 'iface2' static1 INTERFACE_LINK_LIBRARIES: '\$' main LINK_LIBRARIES: 'static1;object1' main INTERFACE_LINK_LIBRARIES: '' +iface10 LINK_LIBRARIES: '' +iface10 INTERFACE_LINK_LIBRARIES: '' +iface11 LINK_LIBRARIES: '' +iface11 INTERFACE_LINK_LIBRARIES: 'iface10' +static10 LINK_LIBRARIES: 'iface11;iface10' +static10 INTERFACE_LINK_LIBRARIES: 'iface11;iface10' +static11 LINK_LIBRARIES: 'static10;iface11;iface11;iface10;iface10' +static11 INTERFACE_LINK_LIBRARIES: 'static10;iface11;iface11;iface10;iface10' +main10 LINK_LIBRARIES: 'static11;static10;static10;iface11;iface11;iface10;iface10;iface11;iface10' +main10 INTERFACE_LINK_LIBRARIES: '' ]]) string(REGEX REPLACE "\r\n" "\n" expect "${expect}") string(REGEX REPLACE "\n+$" "" expect "${expect}") diff --git a/Tests/CustomTransitiveProperties/main10.c b/Tests/CustomTransitiveProperties/main10.c new file mode 100644 index 0000000..369683c --- /dev/null +++ b/Tests/CustomTransitiveProperties/main10.c @@ -0,0 +1,7 @@ +extern int static10(void); +extern int static11(void); + +int main(void) +{ + return static10() + static11(); +} diff --git a/Tests/CustomTransitiveProperties/static10.c b/Tests/CustomTransitiveProperties/static10.c new file mode 100644 index 0000000..6359f22 --- /dev/null +++ b/Tests/CustomTransitiveProperties/static10.c @@ -0,0 +1,4 @@ +int static10(void) +{ + return 0; +} diff --git a/Tests/CustomTransitiveProperties/static11.c b/Tests/CustomTransitiveProperties/static11.c new file mode 100644 index 0000000..0ba822d --- /dev/null +++ b/Tests/CustomTransitiveProperties/static11.c @@ -0,0 +1,4 @@ +int static11(void) +{ + return 0; +} -- cgit v0.12 From 161f703e76920b03fdc1a1044c65ac6a9fffec0e Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 22 Feb 2025 16:57:43 -0500 Subject: GenEx: Restore evaluation context for conditional transitive properties In commit e8010b67c7 (cmGeneratorExpressionDAGChecker: Make local generator available in constructor, 2024-04-25, v3.30.0-rc1~172^2~6) we accidentally failed to preserve `EvaluateInterfaceProperty`'s consistency with `TargetPropertyNode::Evaluate`. Fix its local generator selection to match the evaluation context. --- Source/cmGeneratorTarget_TransitiveProperty.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index 8c5d9bd..19300cc 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -114,7 +114,7 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( prop, nullptr, dagCheckerParent, - this->LocalGenerator, + context->LG, context->Config, context->Backtrace, }; -- cgit v0.12 From 8b5af40b34f846c0a0d7d7e7e851db9179442f06 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 22 Feb 2025 07:39:04 -0500 Subject: GenEx: Fix evaluation of LINK_LIBRARIES as custom transitive property Fix logic from commit b9ee79b8a1 (GenEx: Add support for custom transitive compile properties, 2024-05-09, v3.30.0-rc1~82^2~1) to more precisely know when we are computing the link dependency graph. Issue: #20416 Issue: #26709 --- Source/cmGeneratorExpressionDAGChecker.cxx | 12 +++++++++--- Source/cmGeneratorExpressionDAGChecker.h | 16 +++++++++++++++- Source/cmGeneratorExpressionNode.cxx | 3 +-- Source/cmGeneratorTarget.h | 3 ++- Source/cmGeneratorTarget_Link.cxx | 18 ++++++++++++++++-- Source/cmGeneratorTarget_TransitiveProperty.cxx | 9 ++++----- Tests/CustomTransitiveProperties/CMakeLists.txt | 8 +++----- Tests/CustomTransitiveProperties/check.cmake | 6 +++--- 8 files changed, 53 insertions(+), 22 deletions(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 8e28b42..c275ec6 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -21,21 +21,22 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( cmGeneratorTarget const* target, std::string property, GeneratorExpressionContent const* content, cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG, - std::string const& contextConfig, cmListFileBacktrace backtrace) + std::string const& contextConfig, cmListFileBacktrace backtrace, + ComputingLinkLibraries computingLinkLibraries) : Parent(parent) , Top(parent ? parent->Top : this) , Target(target) , Property(std::move(property)) , Content(content) , Backtrace(std::move(backtrace)) + , ComputingLinkLibraries_(computingLinkLibraries) { if (parent) { this->TopIsTransitiveProperty = parent->TopIsTransitiveProperty; } else { this->TopIsTransitiveProperty = this->Target - ->IsTransitiveProperty(this->Property, contextLG, contextConfig, - this->EvaluatingLinkLibraries()) + ->IsTransitiveProperty(this->Property, contextLG, contextConfig, this) .has_value(); } @@ -193,6 +194,11 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkerLauncher() const "_LINKER_LAUNCHER"_s; } +bool cmGeneratorExpressionDAGChecker::IsComputingLinkLibraries() const +{ + return this->Top->ComputingLinkLibraries_ == ComputingLinkLibraries::Yes; +} + bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries( cmGeneratorTarget const* tgt, ForGenex genex) const { diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 5b4e6d6..064804f 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -17,12 +17,19 @@ class cmLocalGenerator; struct cmGeneratorExpressionDAGChecker { + enum class ComputingLinkLibraries + { + No, + Yes, + }; cmGeneratorExpressionDAGChecker( cmGeneratorTarget const* target, std::string property, GeneratorExpressionContent const* content, cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG, std::string const& contextConfig, - cmListFileBacktrace backtrace = cmListFileBacktrace()); + cmListFileBacktrace backtrace = cmListFileBacktrace(), + ComputingLinkLibraries computingLinkLibraries = + ComputingLinkLibraries::No); enum Result { @@ -45,6 +52,11 @@ struct cmGeneratorExpressionDAGChecker bool EvaluatingLinkOptionsExpression() const; bool EvaluatingLinkerLauncher() const; + /** Returns true only when computing the actual link dependency + graph for cmGeneratorTarget::GetLinkImplementationLibraries + or cmGeneratorTarget::GetLinkInterfaceLibraries. */ + bool IsComputingLinkLibraries() const; + enum class ForGenex { ANY, @@ -78,4 +90,6 @@ private: bool TransitivePropertiesOnly = false; bool CMP0131 = false; bool TopIsTransitiveProperty = false; + ComputingLinkLibraries const ComputingLinkLibraries_ = + ComputingLinkLibraries::No; }; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 8bd263d..0713bc7 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2957,8 +2957,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (cm::optional transitiveProp = target->IsTransitiveProperty(propertyName, context->LG, - context->Config, - evaluatingLinkLibraries)) { + context->Config, dagCheckerParent)) { interfacePropertyName = std::string(transitiveProp->InterfaceName); isInterfaceProperty = transitiveProp->InterfaceName == propertyName; usage = transitiveProp->Usage; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1e6ff78..0a92252 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -935,7 +935,8 @@ public: cm::optional IsTransitiveProperty( cm::string_view prop, cmLocalGenerator const* lg, - std::string const& config, bool evaluatingLinkLibraries) const; + std::string const& config, + cmGeneratorExpressionDAGChecker const* dagChecker) const; bool HaveInstallTreeRPATH(const std::string& config) const; diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index e1db657..74e77de 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -565,7 +565,14 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, } // Keep this logic in sync with ComputeLinkImplementationLibraries. cmGeneratorExpressionDAGChecker dagChecker{ - this, prop, nullptr, nullptr, this->LocalGenerator, config, + this, + prop, + nullptr, + nullptr, + this->LocalGenerator, + config, + cmListFileBacktrace(), + cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes, }; // The $ expression may be in a link interface to specify // private link dependencies that are otherwise excluded from usage @@ -1322,7 +1329,14 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( for (auto const& entry : entryRange) { // Keep this logic in sync with ExpandLinkItems. cmGeneratorExpressionDAGChecker dagChecker{ - this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config, + this, + "LINK_LIBRARIES", + nullptr, + nullptr, + this->LocalGenerator, + config, + cmListFileBacktrace(), + cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes, }; // The $ expression may be used to specify link dependencies // that are otherwise excluded from usage requirements. diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index 19300cc..7c197fc 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -183,10 +183,9 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( } cm::optional -cmGeneratorTarget::IsTransitiveProperty(cm::string_view prop, - cmLocalGenerator const* lg, - std::string const& config, - bool evaluatingLinkLibraries) const +cmGeneratorTarget::IsTransitiveProperty( + cm::string_view prop, cmLocalGenerator const* lg, std::string const& config, + cmGeneratorExpressionDAGChecker const* dagChecker) const { cm::optional result; static const cm::string_view kINTERFACE_ = "INTERFACE_"_s; @@ -215,7 +214,7 @@ cmGeneratorTarget::IsTransitiveProperty(cm::string_view prop, result = TransitiveProperty{ "INTERFACE_COMPILE_DEFINITIONS"_s, UseTo::Compile }; } - } else if (!evaluatingLinkLibraries) { + } else if (!dagChecker || !dagChecker->IsComputingLinkLibraries()) { // Honor TRANSITIVE_COMPILE_PROPERTIES and TRANSITIVE_LINK_PROPERTIES // from the link closure when we are not evaluating the closure itself. CustomTransitiveProperties const& ctp = diff --git a/Tests/CustomTransitiveProperties/CMakeLists.txt b/Tests/CustomTransitiveProperties/CMakeLists.txt index 128687f..a9ac2b8 100644 --- a/Tests/CustomTransitiveProperties/CMakeLists.txt +++ b/Tests/CustomTransitiveProperties/CMakeLists.txt @@ -200,14 +200,12 @@ add_custom_target(check ALL VERBATIM # / \ # "static10[iface11];iface11[iface10]" "$" "iface11;iface10" - "$" "static10;iface11;iface11;iface10;iface10" - # / / \ \ \___ extra! + "$" "static10;iface11;iface11;iface10" # __/ __/ \__ \__________ # / / \ \ # "static11[static10;iface11];static10[iface11;iface11[iface10]]" - "$" "static10;iface11;iface11;iface10;iface10" - "$" "static11;static10;static10;iface11;iface11;iface10;iface10;iface11;iface10" - # / / | | \ \ \_______\_______\____ extra! + "$" "static10;iface11;iface11;iface10" + "$" "static11;static10;static10;iface11;iface11;iface10" # _______/ _______/ | | \______ \______________ # / / | | \ \ # "main10[static11;static10];static11[static10;iface11;static10[iface11;iface11[iface10]]]" diff --git a/Tests/CustomTransitiveProperties/check.cmake b/Tests/CustomTransitiveProperties/check.cmake index 31a5c9f..0798542 100644 --- a/Tests/CustomTransitiveProperties/check.cmake +++ b/Tests/CustomTransitiveProperties/check.cmake @@ -47,9 +47,9 @@ iface11 LINK_LIBRARIES: '' iface11 INTERFACE_LINK_LIBRARIES: 'iface10' static10 LINK_LIBRARIES: 'iface11;iface10' static10 INTERFACE_LINK_LIBRARIES: 'iface11;iface10' -static11 LINK_LIBRARIES: 'static10;iface11;iface11;iface10;iface10' -static11 INTERFACE_LINK_LIBRARIES: 'static10;iface11;iface11;iface10;iface10' -main10 LINK_LIBRARIES: 'static11;static10;static10;iface11;iface11;iface10;iface10;iface11;iface10' +static11 LINK_LIBRARIES: 'static10;iface11;iface11;iface10' +static11 INTERFACE_LINK_LIBRARIES: 'static10;iface11;iface11;iface10' +main10 LINK_LIBRARIES: 'static11;static10;static10;iface11;iface11;iface10' main10 INTERFACE_LINK_LIBRARIES: '' ]]) string(REGEX REPLACE "\r\n" "\n" expect "${expect}") -- cgit v0.12