From 42ca2a2062acb614e8c232f7f83c9fda27f3c5fb Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sat, 28 Feb 2026 15:57:48 +0100 Subject: [PATCH] cmEvaluatedTargetProperty: put declarations in namespace cm --- Source/cmEvaluatedTargetProperty.cxx | 2 + Source/cmEvaluatedTargetProperty.h | 2 + .../cmGeneratorTarget_IncludeDirectories.cxx | 15 +++--- Source/cmGeneratorTarget_LinkDirectories.cxx | 11 ++-- Source/cmGeneratorTarget_Options.cxx | 51 ++++++++++--------- Source/cmGeneratorTarget_Sources.cxx | 27 +++++----- Source/cmQtAutoGenInitializer.cxx | 12 ++--- 7 files changed, 66 insertions(+), 54 deletions(-) diff --git a/Source/cmEvaluatedTargetProperty.cxx b/Source/cmEvaluatedTargetProperty.cxx index 43c550fabe..344aef4ac5 100644 --- a/Source/cmEvaluatedTargetProperty.cxx +++ b/Source/cmEvaluatedTargetProperty.cxx @@ -14,6 +14,7 @@ struct cmGeneratorExpressionDAGChecker; +namespace cm { EvaluatedTargetPropertyEntry::EvaluatedTargetPropertyEntry( cmLinkItem const& item, cmListFileBacktrace bt) : LinkItem(item) @@ -107,3 +108,4 @@ void AddInterfaceEntries(cmGeneratorTarget const* headTarget, } } } +} diff --git a/Source/cmEvaluatedTargetProperty.h b/Source/cmEvaluatedTargetProperty.h index fa2bc8c131..db001078f7 100644 --- a/Source/cmEvaluatedTargetProperty.h +++ b/Source/cmEvaluatedTargetProperty.h @@ -20,6 +20,7 @@ struct Context; class cmLinkItem; struct cmGeneratorExpressionDAGChecker; +namespace cm { // Represent a target property entry after evaluating generator expressions // and splitting up lists. struct EvaluatedTargetPropertyEntry @@ -82,3 +83,4 @@ void AddInterfaceEntries( EvaluatedTargetPropertyEntries& entries, IncludeRuntimeInterface searchRuntime, cmGeneratorTarget::UseTo usage = cmGeneratorTarget::UseTo::Compile); +} diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index c91d25b7ff..b8047e86f9 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -97,7 +97,7 @@ std::string AddLangSpecificInterfaceIncludeDirectories( void AddLangSpecificImplicitIncludeDirectories( cmGeneratorTarget const* target, std::string const& lang, std::string const& config, std::string const& propertyName, - IncludeDirectoryFallBack mode, EvaluatedTargetPropertyEntries& entries) + IncludeDirectoryFallBack mode, cm::EvaluatedTargetPropertyEntries& entries) { if (auto const* libraries = target->GetLinkImplementationLibraries(config, UseTo::Compile)) { @@ -113,7 +113,7 @@ void AddLangSpecificImplicitIncludeDirectories( } if (cm::contains(dependency->GetAllConfigCompileLanguages(), lang)) { auto* lg = dependency->GetLocalGenerator(); - EvaluatedTargetPropertyEntry entry{ library, library.Backtrace }; + cm::EvaluatedTargetPropertyEntry entry{ library, library.Backtrace }; if (lang == "Swift") { entry.Values.emplace_back( @@ -141,12 +141,12 @@ void AddLangSpecificImplicitIncludeDirectories( } void processIncludeDirectories(cmGeneratorTarget const* tgt, - EvaluatedTargetPropertyEntries& entries, + cm::EvaluatedTargetPropertyEntries& entries, std::vector>& includes, std::unordered_set& uniqueIncludes, bool debugIncludes) { - for (EvaluatedTargetPropertyEntry& entry : entries.Entries) { + for (cm::EvaluatedTargetPropertyEntry& entry : entries.Entries) { cmLinkItem const& item = entry.LinkItem; std::string const& targetName = item.AsStr(); bool const fromImported = item.Target && item.Target->IsImported(); @@ -237,8 +237,9 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( this->DebugIncludesDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->IncludeDirectoriesEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->IncludeDirectoriesEntries); if (lang == "Swift") { AddLangSpecificImplicitIncludeDirectories( @@ -266,7 +267,7 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( } AddInterfaceEntries(this, "INTERFACE_INCLUDE_DIRECTORIES", context, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + &dagChecker, entries, cm::IncludeRuntimeInterface::Yes); processIncludeDirectories(this, entries, includes, uniqueIncludes, debugIncludes); diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index 8f11a0560a..8f297943fc 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -30,12 +30,12 @@ namespace { void processLinkDirectories(cmGeneratorTarget const* tgt, - EvaluatedTargetPropertyEntries& entries, + cm::EvaluatedTargetPropertyEntries& entries, std::vector>& directories, std::unordered_set& uniqueDirectories, bool debugDirectories) { - for (EvaluatedTargetPropertyEntry& entry : entries.Entries) { + for (cm::EvaluatedTargetPropertyEntry& entry : entries.Entries) { cmLinkItem const& item = entry.LinkItem; std::string const& targetName = item.AsStr(); @@ -135,11 +135,12 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( this->DebugLinkDirectoriesDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->LinkDirectoriesEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->LinkDirectoriesEntries); AddInterfaceEntries(this, "INTERFACE_LINK_DIRECTORIES", context, &dagChecker, - entries, IncludeRuntimeInterface::Yes, + entries, cm::IncludeRuntimeInterface::Yes, this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link : UseTo::Compile); diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index 2244e465d0..2fee725de7 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -49,14 +49,14 @@ auto const DL_BEGIN = ""_s; auto const DL_END = ""_s; void processOptions(cmGeneratorTarget const* tgt, - EvaluatedTargetPropertyEntries const& entries, + cm::EvaluatedTargetPropertyEntries const& entries, std::vector>& options, std::unordered_set& uniqueOptions, bool debugOptions, char const* logName, OptionsParse parse, bool processDeviceOptions = false) { bool splitOption = !processDeviceOptions; - for (EvaluatedTargetPropertyEntry const& entry : entries.Entries) { + for (cm::EvaluatedTargetPropertyEntry const& entry : entries.Entries) { std::string usedOptions; for (std::string const& opt : entry.Values) { if (processDeviceOptions && (opt == DL_BEGIN || opt == DL_END)) { @@ -222,7 +222,7 @@ constexpr char SBCS_DEFINITION_PREFIX[] = "_SBCS="; MsvcCharSetInfo GetMsvcCharSetInfo( cmGeneratorTarget const& tgt, std::string const& lang, - EvaluatedTargetPropertyEntries const& entries) + cm::EvaluatedTargetPropertyEntries const& entries) { using MsvcCharSet = cmGeneratorTarget::MsvcCharSet; @@ -235,7 +235,7 @@ MsvcCharSetInfo GetMsvcCharSetInfo( return { MsvcCharSet::None, false }; } - for (EvaluatedTargetPropertyEntry const& entry : entries.Entries) { + for (cm::EvaluatedTargetPropertyEntry const& entry : entries.Entries) { for (std::string const& value : entry.Values) { MsvcCharSet charSet = cmGeneratorTarget::GetMsvcCharSet(value); if (charSet != MsvcCharSet::None) { @@ -289,11 +289,12 @@ std::vector> cmGeneratorTarget::GetCompileOptions( this->DebugCompileOptionsDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->CompileOptionsEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->CompileOptionsEntries); AddInterfaceEntries(this, "INTERFACE_COMPILE_OPTIONS", context, &dagChecker, - entries, IncludeRuntimeInterface::Yes); + entries, cm::IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueOptions, debugOptions, "compile options", OptionsParse::Shell); @@ -332,11 +333,12 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( this->DebugCompileFeaturesDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->CompileFeaturesEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->CompileFeaturesEntries); AddInterfaceEntries(this, "INTERFACE_COMPILE_FEATURES", context, &dagChecker, - entries, IncludeRuntimeInterface::Yes); + entries, cm::IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueFeatures, debugFeatures, "compile features", OptionsParse::None); @@ -382,11 +384,12 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( this->DebugCompileDefinitionsDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->CompileDefinitionsEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->CompileDefinitionsEntries); AddInterfaceEntries(this, "INTERFACE_COMPILE_DEFINITIONS", context, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + &dagChecker, entries, cm::IncludeRuntimeInterface::Yes); // Add the character set definition MsvcCharSetInfo charSetInfo = GetMsvcCharSetInfo(*this, language, entries); @@ -449,11 +452,12 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( this->DebugPrecompileHeadersDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->PrecompileHeadersEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->PrecompileHeadersEntries); AddInterfaceEntries(this, "INTERFACE_PRECOMPILE_HEADERS", context, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + &dagChecker, entries, cm::IncludeRuntimeInterface::Yes); std::vector> list; processOptions(this, entries, list, uniqueOptions, debugDefines, @@ -507,11 +511,12 @@ std::vector> cmGeneratorTarget::GetLinkOptions( this->DebugLinkOptionsDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->LinkOptionsEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->LinkOptionsEntries); AddInterfaceEntries(this, "INTERFACE_LINK_OPTIONS", context, &dagChecker, - entries, IncludeRuntimeInterface::Yes, + entries, cm::IncludeRuntimeInterface::Yes, this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link : UseTo::Compile); @@ -684,12 +689,12 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( this, "STATIC_LIBRARY_OPTIONS", nullptr, nullptr, context, }; - EvaluatedTargetPropertyEntries entries; + cm::EvaluatedTargetPropertyEntries entries; if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) { std::unique_ptr entry = TargetPropertyEntry::Create( *this->LocalGenerator->GetCMakeInstance(), *linkOptions); entries.Entries.emplace_back( - EvaluateTargetPropertyEntry(this, context, &dagChecker, *entry)); + cm::EvaluateTargetPropertyEntry(this, context, &dagChecker, *entry)); } processOptions(this, entries, result, uniqueOptions, false, "static library link options", OptionsParse::Shell); @@ -729,7 +734,7 @@ std::vector> cmGeneratorTarget::GetLinkDepends( this, "LINK_DEPENDS", nullptr, nullptr, context, }; - EvaluatedTargetPropertyEntries entries; + cm::EvaluatedTargetPropertyEntries entries; if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) { cmList depends{ *linkDepends }; for (auto const& depend : depends) { @@ -740,7 +745,7 @@ std::vector> cmGeneratorTarget::GetLinkDepends( } } AddInterfaceEntries(this, "INTERFACE_LINK_DEPENDS", context, &dagChecker, - entries, IncludeRuntimeInterface::Yes, + entries, cm::IncludeRuntimeInterface::Yes, this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link : UseTo::Compile); diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index 532f42ee02..3cd5a54da7 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -53,7 +53,7 @@ using UseTo = cmGeneratorTarget::UseTo; void AddObjectEntries(cmGeneratorTarget const* headTarget, cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, - EvaluatedTargetPropertyEntries& entries) + cm::EvaluatedTargetPropertyEntries& entries) { if (cmLinkImplementationLibraries const* impl = headTarget->GetLinkImplementationLibraries(context.Config, @@ -73,7 +73,7 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, ge.Parse(std::move(genex)); cge->SetEvaluateForBuildsystem(true); - EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); + cm::EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); cmExpandList(cge->Evaluate(context, dagChecker, headTarget), ee.Values); if (cge->GetHadContextSensitiveCondition()) { @@ -89,7 +89,7 @@ void AddFileSetEntries(cmGeneratorTarget const* headTarget, cmGeneratorFileSets const* fileSets, cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, - EvaluatedTargetPropertyEntries& entries) + cm::EvaluatedTargetPropertyEntries& entries) { auto sources = fileSets->GetSources(context, headTarget, dagChecker); entries = @@ -97,7 +97,7 @@ void AddFileSetEntries(cmGeneratorTarget const* headTarget, } bool processSources(cmGeneratorTarget const* tgt, std::string const& config, - EvaluatedTargetPropertyEntries& entries, + cm::EvaluatedTargetPropertyEntries& entries, std::vector>& srcs, std::unordered_set& uniqueSrcs, bool debugSources, @@ -107,7 +107,7 @@ bool processSources(cmGeneratorTarget const* tgt, std::string const& config, bool contextDependent = entries.HadContextSensitiveCondition; - for (EvaluatedTargetPropertyEntry& entry : entries.Entries) { + for (cm::EvaluatedTargetPropertyEntry& entry : entries.Entries) { if (entry.ContextDependent) { contextDependent = true; } @@ -213,18 +213,19 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( this, "SOURCES", nullptr, nullptr, context, }; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context, &dagChecker, this->SourceEntries); + cm::EvaluatedTargetPropertyEntries entries = + cm::EvaluateTargetPropertyEntries(this, context, &dagChecker, + this->SourceEntries); std::unordered_set uniqueSrcs; bool contextDependentDirectSources = processSources(this, config, entries, files, uniqueSrcs, debugSources); // Collect INTERFACE_SOURCES of all direct link-dependencies. - EvaluatedTargetPropertyEntries linkInterfaceSourcesEntries; - AddInterfaceEntries(this, "INTERFACE_SOURCES", context, &dagChecker, - linkInterfaceSourcesEntries, IncludeRuntimeInterface::No, - UseTo::Compile); + cm::EvaluatedTargetPropertyEntries linkInterfaceSourcesEntries; + cm::AddInterfaceEntries(this, "INTERFACE_SOURCES", context, &dagChecker, + linkInterfaceSourcesEntries, + cm::IncludeRuntimeInterface::No, UseTo::Compile); bool contextDependentInterfaceSources = processSources(this, config, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources); @@ -232,7 +233,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( // Collect TARGET_OBJECTS of direct object link-dependencies. bool contextDependentObjects = false; if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) { - EvaluatedTargetPropertyEntries linkObjectsEntries; + cm::EvaluatedTargetPropertyEntries linkObjectsEntries; AddObjectEntries(this, context, &dagChecker, linkObjectsEntries); contextDependentObjects = processSources(this, config, linkObjectsEntries, files, uniqueSrcs, debugSources); @@ -243,7 +244,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( } // Collect this target's file sets. - EvaluatedTargetPropertyEntries fileSetEntries; + cm::EvaluatedTargetPropertyEntries fileSetEntries; AddFileSetEntries(this, this->FileSets.get(), context, &dagChecker, fileSetEntries); auto processFileSetEntry = [this, &config](cmSourceFile* sf) { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 4075cad7d9..05b8a515e7 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1999,7 +1999,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() info.SetBool("MOC_RELAXED_MODE", this->Moc.RelaxedMode); info.SetBool("MOC_PATH_PREFIX", this->Moc.PathPrefix); - EvaluatedTargetPropertyEntries InterfaceAutoMocMacroNamesEntries; + cm::EvaluatedTargetPropertyEntries InterfaceAutoMocMacroNamesEntries; if (this->MultiConfig) { for (auto const& cfg : this->ConfigsList) { @@ -2008,10 +2008,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() cmGeneratorExpressionDAGChecker dagChecker{ this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, context, }; - AddInterfaceEntries(this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", - context, &dagChecker, - InterfaceAutoMocMacroNamesEntries, - IncludeRuntimeInterface::Yes); + cm::AddInterfaceEntries( + this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", context, + &dagChecker, InterfaceAutoMocMacroNamesEntries, + cm::IncludeRuntimeInterface::Yes); } } } else { @@ -2021,7 +2021,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() }; AddInterfaceEntries( this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", context, &dagChecker, - InterfaceAutoMocMacroNamesEntries, IncludeRuntimeInterface::Yes); + InterfaceAutoMocMacroNamesEntries, cm::IncludeRuntimeInterface::Yes); } for (auto const& entry : InterfaceAutoMocMacroNamesEntries.Entries) {