From d4d204382f3faeea51bff005ae3cd602c46bb39c Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 21 Sep 2025 11:39:02 -0400 Subject: [PATCH 1/3] GenEx: Collect evaluation arguments into local Context structures --- Source/cmCommonTargetGenerator.cxx | 10 +- Source/cmComputeLinkDepends.cxx | 33 ++++--- Source/cmComputeLinkDepends.h | 5 +- Source/cmDyndepCollation.cxx | 6 +- Source/cmExportBuildCMakeConfigGenerator.cxx | 11 ++- .../cmExportInstallCMakeConfigGenerator.cxx | 8 +- Source/cmExportTryCompileFileGenerator.cxx | 17 ++-- Source/cmFileAPICodemodel.cxx | 21 ++-- Source/cmGeneratorExpression.cxx | 11 ++- .../cmGeneratorExpressionEvaluationFile.cxx | 22 +++-- Source/cmGeneratorTarget.cxx | 56 ++++++----- .../cmGeneratorTarget_IncludeDirectories.cxx | 37 +++---- Source/cmGeneratorTarget_Link.cxx | 22 +++-- Source/cmGeneratorTarget_LinkDirectories.cxx | 15 +-- Source/cmGeneratorTarget_Options.cxx | 98 ++++++++++++------- Source/cmGeneratorTarget_Sources.cxx | 26 +++-- Source/cmInstallFileSetGenerator.cxx | 9 +- Source/cmMakefileTargetGenerator.cxx | 10 +- Source/cmQtAutoGenInitializer.cxx | 25 ++--- 19 files changed, 255 insertions(+), 187 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 867f1af298..616975019e 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -11,6 +11,7 @@ #include #include "cmComputeLinkInformation.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorTarget.h" @@ -521,13 +522,14 @@ std::string cmCommonTargetGenerator::GetLinkerLauncher( std::string propName = lang + "_LINKER_LAUNCHER"; cmValue launcherProp = this->GeneratorTarget->GetProperty(propName); if (cmNonempty(launcherProp)) { + cm::GenEx::Context context(this->LocalCommonGenerator, config, lang); cmGeneratorExpressionDAGChecker dagChecker{ - this->GeneratorTarget, propName, nullptr, nullptr, - this->LocalCommonGenerator, config, + this->GeneratorTarget, propName, nullptr, nullptr, context.LG, + context.Config }; std::string evaluatedLinklauncher = cmGeneratorExpression::Evaluate( - *launcherProp, this->LocalCommonGenerator, config, this->GeneratorTarget, - &dagChecker, this->GeneratorTarget, lang); + *launcherProp, context.LG, context.Config, this->GeneratorTarget, + &dagChecker, this->GeneratorTarget, context.Language); // Convert ;-delimited list to single string cmList args{ evaluatedLinklauncher, cmList::EmptyElements::Yes }; if (!args.empty()) { diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index ed23958f16..adb4be5aa3 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -19,6 +19,7 @@ #include "cmsys/RegularExpression.hxx" #include "cmComputeComponentGraph.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorTarget.h" @@ -599,29 +600,31 @@ std::string const& cmComputeLinkDepends::LinkEntry::DEFAULT = cmLinkItem::DEFAULT; cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target, - std::string const& config, - std::string const& linkLanguage, + std::string config, + std::string linkLanguage, LinkLibrariesStrategy strategy) : Target(target) , Makefile(this->Target->Target->GetMakefile()) , GlobalGenerator(this->Target->GetLocalGenerator()->GetGlobalGenerator()) , CMakeInstance(this->GlobalGenerator->GetCMakeInstance()) - , Config(config) + , Config(std::move(config)) , DebugMode(this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE") || this->Target->GetProperty("LINK_DEPENDS_DEBUG_MODE").IsOn()) - , LinkLanguage(linkLanguage) + , LinkLanguage(std::move(linkLanguage)) , LinkType(ComputeLinkType( this->Config, this->Makefile->GetCMakeInstance()->GetDebugConfigs())) , Strategy(strategy) { + cm::GenEx::Context context(this->Target->LocalGenerator, this->Config, + this->LinkLanguage); // target oriented feature override property takes precedence over // global override property cm::string_view lloPrefix = "LINK_LIBRARY_OVERRIDE_"_s; auto const& keys = this->Target->GetPropertyKeys(); std::for_each( keys.cbegin(), keys.cend(), - [this, &lloPrefix, &config, &linkLanguage](std::string const& key) { + [this, &lloPrefix, &context](std::string const& key) { if (cmHasPrefix(key, lloPrefix)) { if (cmValue feature = this->Target->GetProperty(key)) { if (!feature->empty() && key.length() > lloPrefix.length()) { @@ -631,13 +634,13 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, - this->Target->GetLocalGenerator(), - config, + context.LG, + context.Config, this->Target->GetBacktrace(), }; auto overrideFeature = cmGeneratorExpression::Evaluate( - *feature, this->Target->GetLocalGenerator(), config, - this->Target, &dagChecker, this->Target, linkLanguage); + *feature, context.LG, context.Config, this->Target, &dagChecker, + this->Target, context.Language); this->LinkLibraryOverride.emplace(item, overrideFeature); } } @@ -647,17 +650,17 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target, if (cmValue linkLibraryOverride = this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) { cmGeneratorExpressionDAGChecker dagChecker{ - target, + this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, - target->GetLocalGenerator(), - config, - target->GetBacktrace(), + context.LG, + context.Config, + this->Target->GetBacktrace(), }; auto overrideValue = cmGeneratorExpression::Evaluate( - *linkLibraryOverride, target->GetLocalGenerator(), config, target, - &dagChecker, target, linkLanguage); + *linkLibraryOverride, context.LG, context.Config, this->Target, + &dagChecker, this->Target, context.Language); std::vector overrideList = cmTokenize(overrideValue, ',', cmTokenizerMode::New); diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index a82db2b693..3f9f6e2a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -39,9 +39,8 @@ enum class LinkLibrariesStrategy class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmGeneratorTarget const* target, - std::string const& config, - std::string const& linkLanguage, + cmComputeLinkDepends(cmGeneratorTarget const* target, std::string config, + std::string linkLanguage, LinkLibrariesStrategy strategy); ~cmComputeLinkDepends(); diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx index 54d283bc16..bc79df5832 100644 --- a/Source/cmDyndepCollation.cxx +++ b/Source/cmDyndepCollation.cxx @@ -20,6 +20,7 @@ #include "cmExportBuildFileGenerator.h" #include "cmExportSet.h" #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" // IWYU pragma: keep #include "cmGeneratorTarget.h" @@ -50,6 +51,7 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt, std::string const& config, cmDyndepGeneratorCallbacks const& cb) { + cm::GenEx::Context const context(gt->LocalGenerator, config); TdiSourceInfo info; cmTarget const* tgt = gt->Target; auto all_file_sets = tgt->GetAllFileSetNames(); @@ -109,11 +111,11 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt, auto directoryEntries = file_set->CompileDirectoryEntries(); auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, gt->LocalGenerator, config, gt); + directoryEntries, context.LG, context.Config, gt); std::map> files_per_dirs; for (auto const& entry : fileEntries) { file_set->EvaluateFileEntry(directories, files_per_dirs, entry, - gt->LocalGenerator, config, gt); + context.LG, context.Config, gt); } Json::Value fs_dest = Json::nullValue; diff --git a/Source/cmExportBuildCMakeConfigGenerator.cxx b/Source/cmExportBuildCMakeConfigGenerator.cxx index 1e58d79889..e66e88f8fc 100644 --- a/Source/cmExportBuildCMakeConfigGenerator.cxx +++ b/Source/cmExportBuildCMakeConfigGenerator.cxx @@ -17,6 +17,7 @@ #include "cmCryptoHash.h" #include "cmExportSet.h" #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -176,8 +177,9 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetDirectories( auto directoryEntries = fileSet->CompileDirectoryEntries(); for (auto const& config : configs) { + cm::GenEx::Context context(gte->LocalGenerator, config); auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, gte->LocalGenerator, config, gte); + directoryEntries, context.LG, context.Config, gte); bool const contextSensitive = std::any_of(directoryEntries.begin(), directoryEntries.end(), @@ -226,13 +228,14 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetFiles( auto directoryEntries = fileSet->CompileDirectoryEntries(); for (auto const& config : configs) { + cm::GenEx::Context context(gte->LocalGenerator, config); auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, gte->LocalGenerator, config, gte); + directoryEntries, context.LG, context.Config, gte); std::map> files; for (auto const& entry : fileEntries) { - fileSet->EvaluateFileEntry(directories, files, entry, - gte->LocalGenerator, config, gte); + fileSet->EvaluateFileEntry(directories, files, entry, context.LG, + context.Config, gte); } bool const contextSensitive = diff --git a/Source/cmExportInstallCMakeConfigGenerator.cxx b/Source/cmExportInstallCMakeConfigGenerator.cxx index 166833d3c4..7ebeb723ff 100644 --- a/Source/cmExportInstallCMakeConfigGenerator.cxx +++ b/Source/cmExportInstallCMakeConfigGenerator.cxx @@ -16,6 +16,7 @@ #include "cmExportFileGenerator.h" #include "cmExportSet.h" #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -339,13 +340,14 @@ std::string cmExportInstallCMakeConfigGenerator::GetFileSetFiles( te->FileSetGenerators.at(fileSet->GetName())->GetDestination()); for (auto const& config : configs) { + cm::GenEx::Context context(gte->LocalGenerator, config); auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, gte->LocalGenerator, config, gte); + directoryEntries, context.LG, context.Config, gte); std::map> files; for (auto const& entry : fileEntries) { - fileSet->EvaluateFileEntry(directories, files, entry, - gte->LocalGenerator, config, gte); + fileSet->EvaluateFileEntry(directories, files, entry, context.LG, + context.Config, gte); } auto unescapedDest = destCge->Evaluate(gte->LocalGenerator, config, gte); auto dest = diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index e67df5f7b7..ac9cfbbdc4 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -9,6 +9,7 @@ #include #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorTarget.h" @@ -76,6 +77,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets( return std::string(); } + cm::GenEx::Context context(tgt->LocalGenerator, this->Config, language); + cmGeneratorExpression ge(*tgt->Makefile->GetCMakeInstance()); std::unique_ptr parentDagChecker; @@ -83,16 +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( - tgt, "LINK_OPTIONS", nullptr, nullptr, tgt->GetLocalGenerator(), - this->Config); + tgt, "LINK_OPTIONS", nullptr, nullptr, context.LG, context.Config); } cmGeneratorExpressionDAGChecker dagChecker{ - tgt, - propName, - nullptr, - parentDagChecker.get(), - tgt->GetLocalGenerator(), - this->Config, + tgt, propName, nullptr, parentDagChecker.get(), context.LG, context.Config, }; std::unique_ptr cge = ge.Parse(*prop); @@ -103,8 +100,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, - &gDummyHead, &dagChecker, tgt, language); + std::string result = cge->Evaluate(context.LG, context.Config, &gDummyHead, + &dagChecker, tgt, context.Language); std::set const& allTargets = cge->GetAllTargetsSeen(); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 3d6041211f..240c96bf44 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -24,6 +24,7 @@ #include "cmExportSet.h" #include "cmFileAPI.h" #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -1080,16 +1081,17 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) auto* target = installFileSet->GetTarget(); + cm::GenEx::Context context(target->LocalGenerator, this->Config); + auto dirCges = fileSet->CompileDirectoryEntries(); - auto dirs = fileSet->EvaluateDirectoryEntries( - dirCges, target->GetLocalGenerator(), this->Config, target); + auto dirs = fileSet->EvaluateDirectoryEntries(dirCges, context.LG, + context.Config, target); auto entryCges = fileSet->CompileFileEntries(); std::map> entries; for (auto const& entryCge : entryCges) { - fileSet->EvaluateFileEntry(dirs, entries, entryCge, - target->GetLocalGenerator(), this->Config, - target); + fileSet->EvaluateFileEntry(dirs, entries, entryCge, context.LG, + context.Config, target); } Json::Value files = Json::arrayValue; @@ -1608,19 +1610,20 @@ std::pair Target::DumpFileSets() continue; } + cm::GenEx::Context context(this->GT->LocalGenerator, this->Config); + auto fileEntries = fs->CompileFileEntries(); auto directoryEntries = fs->CompileDirectoryEntries(); auto directories = fs->EvaluateDirectoryEntries( - directoryEntries, this->GT->LocalGenerator, this->Config, this->GT); + directoryEntries, context.LG, context.Config, this->GT); fsJson.append(this->DumpFileSet(fs, directories)); std::map> files_per_dirs; for (auto const& entry : fileEntries) { - fs->EvaluateFileEntry(directories, files_per_dirs, entry, - this->GT->LocalGenerator, this->Config, - this->GT); + fs->EvaluateFileEntry(directories, files_per_dirs, entry, context.LG, + context.Config, this->GT); } for (auto const& files_per_dir : files_per_dirs) { diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index ef6e19721b..cba6049bdb 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -454,17 +454,20 @@ std::string const& cmGeneratorExpressionInterpreter::Evaluate( this->CompiledGeneratorExpression = this->GeneratorExpression.Parse(std::move(expression)); + cm::GenEx::Context context(this->LocalGenerator, this->Config, + this->Language); + // Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS cmGeneratorExpressionDAGChecker dagChecker{ this->HeadTarget, property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr, nullptr, - this->LocalGenerator, - this->Config, + context.LG, + context.Config, }; return this->CompiledGeneratorExpression->Evaluate( - this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr, - this->Language); + context.LG, context.Config, this->HeadTarget, &dagChecker, nullptr, + context.Language); } diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 9dd6177cde..d1c352fe97 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -8,6 +8,7 @@ #include "cmsys/FStream.hxx" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmListFileCache.h" @@ -39,11 +40,12 @@ void cmGeneratorExpressionEvaluationFile::Generate( cmCompiledGeneratorExpression* inputExpression, std::map& outputFiles, mode_t perm) { + cm::GenEx::Context context(lg, config, lang); std::string rawCondition = this->Condition->GetInput(); cmGeneratorTarget* target = lg->FindGeneratorTargetToUse(this->Target); if (!rawCondition.empty()) { - std::string condResult = - this->Condition->Evaluate(lg, config, target, nullptr, nullptr, lang); + std::string condResult = this->Condition->Evaluate( + context.LG, context.Config, target, nullptr, nullptr, context.Language); if (condResult == "0") { return; } @@ -58,10 +60,10 @@ void cmGeneratorExpressionEvaluationFile::Generate( } } - std::string const outputFileName = - this->GetOutputFileName(lg, target, config, lang); - std::string const& outputContent = - inputExpression->Evaluate(lg, config, target, nullptr, nullptr, lang); + std::string const outputFileName = this->GetOutputFileName( + context.LG, target, context.Config, context.Language); + std::string const& outputContent = inputExpression->Evaluate( + context.LG, context.Config, target, nullptr, nullptr, context.Language); auto it = outputFiles.find(outputFileName); @@ -207,13 +209,15 @@ std::string cmGeneratorExpressionEvaluationFile::GetOutputFileName( cmLocalGenerator const* lg, cmGeneratorTarget* target, std::string const& config, std::string const& lang) { - std::string outputFileName = - this->OutputFileExpr->Evaluate(lg, config, target, nullptr, nullptr, lang); + cm::GenEx::Context context(lg, config, lang); + std::string outputFileName = this->OutputFileExpr->Evaluate( + context.LG, context.Config, target, nullptr, nullptr, context.Language); if (cmSystemTools::FileIsFullPath(outputFileName)) { outputFileName = cmSystemTools::CollapseFullPath(outputFileName); } else { - outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); + outputFileName = + this->FixRelativePath(outputFileName, PathForOutput, context.LG); } return outputFileName; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 60df703dc3..276af84778 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,7 @@ #include "cmExperimental.h" #include "cmFileSet.h" #include "cmFileTimes.h" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" @@ -630,7 +631,7 @@ std::vector const* cmGeneratorTarget::GetSourceDepends( } namespace { -void handleSystemIncludesDep(cmLocalGenerator* lg, +void handleSystemIncludesDep(cmLocalGenerator const* lg, cmGeneratorTarget const* depTgt, std::string const& config, cmGeneratorTarget const* headTarget, @@ -737,12 +738,13 @@ std::string cmGeneratorTarget::GetLinkerTypeProperty( std::string propName{ "LINKER_TYPE" }; auto linkerType = this->GetProperty(propName); if (!linkerType.IsEmpty()) { + cm::GenEx::Context context(this->LocalGenerator, config, lang); cmGeneratorExpressionDAGChecker dagChecker{ - this, propName, nullptr, nullptr, this->LocalGenerator, config, + this, propName, nullptr, nullptr, context.LG, context.Config, }; - auto ltype = - cmGeneratorExpression::Evaluate(*linkerType, this->GetLocalGenerator(), - config, this, &dagChecker, this, lang); + auto ltype = cmGeneratorExpression::Evaluate( + *linkerType, context.LG, context.Config, this, &dagChecker, this, + context.Language); if (this->IsDeviceLink()) { cmList list{ ltype }; auto const DL_BEGIN = ""_s; @@ -1199,24 +1201,26 @@ void cmGeneratorTarget::AddSystemIncludeCacheKey( std::string const& key, std::string const& config, std::string const& language) const { + cm::GenEx::Context context(this->LocalGenerator, config, language); cmGeneratorExpressionDAGChecker dagChecker{ - this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, - nullptr, this->LocalGenerator, config, + this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr, context.LG, + context.Config, }; bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); cmList result; for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { - result.append(cmGeneratorExpression::Evaluate( - it, this->LocalGenerator, config, this, &dagChecker, nullptr, language)); + result.append( + cmGeneratorExpression::Evaluate(it, context.LG, context.Config, this, + &dagChecker, nullptr, context.Language)); } std::vector const& deps = this->GetLinkImplementationClosure(config, UseTo::Compile); for (cmGeneratorTarget const* dep : deps) { - handleSystemIncludesDep(this->LocalGenerator, dep, config, this, - &dagChecker, result, excludeImported, language); + handleSystemIncludesDep(context.LG, dep, context.Config, this, &dagChecker, + result, excludeImported, context.Language); } cmLinkImplementation const* impl = @@ -1226,9 +1230,9 @@ void cmGeneratorTarget::AddSystemIncludeCacheKey( if (runtimeEntries != impl->LanguageRuntimeLibraries.end()) { for (auto const& lib : runtimeEntries->second) { if (lib.Target) { - handleSystemIncludesDep(this->LocalGenerator, lib.Target, config, - this, &dagChecker, result, excludeImported, - language); + handleSystemIncludesDep(context.LG, lib.Target, context.Config, this, + &dagChecker, result, excludeImported, + context.Language); } } } @@ -1975,11 +1979,12 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector& result, return; } + cm::GenEx::Context context(this->LocalGenerator, config); cmGeneratorExpressionDAGChecker dagChecker{ - this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config, + this, "AUTOUIC_OPTIONS", nullptr, nullptr, context.LG, context.Config, }; - cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator, - config, this, &dagChecker), + cmExpandList(cmGeneratorExpression::Evaluate( + prop, context.LG, context.Config, this, &dagChecker), result); } @@ -5439,17 +5444,18 @@ bool cmGeneratorTarget::AddHeaderSetVerification() bool first = true; for (auto const& config : this->Makefile->GetGeneratorConfigs( cmMakefile::GeneratorConfigQuery::IncludeEmptyConfig)) { + cm::GenEx::Context context(this->LocalGenerator, config); if (first || dirCgesContextSensitive) { - dirs = fileSet->EvaluateDirectoryEntries(dirCges, this->LocalGenerator, - config, this); + dirs = fileSet->EvaluateDirectoryEntries(dirCges, context.LG, + context.Config, this); dirCgesContextSensitive = std::any_of(dirCges.begin(), dirCges.end(), contextSensitive); } if (first || fileCgesContextSensitive) { filesPerDir.clear(); for (auto const& fileCge : fileCges) { - fileSet->EvaluateFileEntry(dirs, filesPerDir, fileCge, - this->LocalGenerator, config, this); + fileSet->EvaluateFileEntry(dirs, filesPerDir, fileCge, context.LG, + context.Config, this); if (fileCge->GetHadContextSensitiveCondition()) { fileCgesContextSensitive = true; } @@ -5980,15 +5986,17 @@ void cmGeneratorTarget::BuildFileSetInfoCache(std::string const& config) const continue; } + cm::GenEx::Context context(this->LocalGenerator, config); + auto fileEntries = file_set->CompileFileEntries(); auto directoryEntries = file_set->CompileDirectoryEntries(); auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, this->LocalGenerator, config, this); + directoryEntries, context.LG, context.Config, this); std::map> files; for (auto const& entry : fileEntries) { - file_set->EvaluateFileEntry(directories, files, entry, - this->LocalGenerator, config, this); + file_set->EvaluateFileEntry(directories, files, entry, context.LG, + context.Config, this); } for (auto const& it : files) { diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index f3161fe74e..1e1bd15734 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -17,6 +17,7 @@ #include #include "cmEvaluatedTargetProperty.h" +#include "cmGenExContext.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGlobalGenerator.h" #include "cmLinkItem.h" @@ -44,15 +45,16 @@ std::string AddLangSpecificInterfaceIncludeDirectories( cmGeneratorTarget const* root, cmGeneratorTarget const* target, std::string const& lang, std::string const& config, std::string const& propertyName, IncludeDirectoryFallBack mode, - cmGeneratorExpressionDAGChecker* context) + cmGeneratorExpressionDAGChecker* dagCheckerParent) { + cm::GenEx::Context context(target->LocalGenerator, config); cmGeneratorExpressionDAGChecker dagChecker{ target, propertyName, nullptr, - context, - target->GetLocalGenerator(), - config, + dagCheckerParent, + context.LG, + context.Config, target->GetBacktrace(), }; switch (dagChecker.Check()) { @@ -103,14 +105,10 @@ void AddLangSpecificImplicitIncludeDirectories( { if (auto const* libraries = target->GetLinkImplementationLibraries(config, UseTo::Compile)) { + cm::GenEx::Context context(target->LocalGenerator, config, lang); cmGeneratorExpressionDAGChecker dagChecker{ - target, - propertyName, - nullptr, - nullptr, - target->GetLocalGenerator(), - config, - target->GetBacktrace(), + target, propertyName, nullptr, nullptr, context.LG, + context.Config, target->GetBacktrace(), }; for (cmLinkImplItem const& library : libraries->Libraries) { @@ -137,8 +135,8 @@ void AddLangSpecificImplicitIncludeDirectories( } cmExpandList(AddLangSpecificInterfaceIncludeDirectories( - target, dependency, lang, config, propertyName, mode, - &dagChecker), + target, dependency, context.Language, context.Config, + propertyName, mode, &dagChecker), entry.Values); entries.Entries.emplace_back(std::move(entry)); } @@ -231,9 +229,10 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( std::vector> includes; std::unordered_set uniqueIncludes; + cm::GenEx::Context context(this->LocalGenerator, config, lang); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "INCLUDE_DIRECTORIES", nullptr, - nullptr, this->LocalGenerator, config, + this, "INCLUDE_DIRECTORIES", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -244,7 +243,8 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( this->DebugIncludesDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, lang, &dagChecker, this->IncludeDirectoriesEntries); + this, context.Config, context.Language, &dagChecker, + this->IncludeDirectoriesEntries); if (lang == "Swift") { AddLangSpecificImplicitIncludeDirectories( @@ -271,8 +271,9 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( entries); } - AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES", lang, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, context.Config, "INTERFACE_INCLUDE_DIRECTORIES", + context.Language, &dagChecker, entries, + IncludeRuntimeInterface::Yes); processIncludeDirectories(this, entries, includes, uniqueIncludes, debugIncludes); diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index 39517553a8..370d4711de 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -25,6 +25,7 @@ #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGlobalGenerator.h" @@ -541,13 +542,15 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, return; } // Keep this logic in sync with ComputeLinkImplementationLibraries. + cm::GenEx::Context context(this->LocalGenerator, config, + headTarget->LinkerLanguage); cmGeneratorExpressionDAGChecker dagChecker{ this, prop, nullptr, nullptr, - this->LocalGenerator, - config, + context.LG, + context.Config, cmListFileBacktrace(), cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes, }; @@ -565,9 +568,8 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, entry.Backtrace); std::unique_ptr cge = ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); - cmList libs{ cge->Evaluate(this->LocalGenerator, config, headTarget, - &dagChecker, this, - headTarget->LinkerLanguage) }; + cmList libs{ cge->Evaluate(context.LG, context.Config, headTarget, + &dagChecker, this, context.Language) }; auto linkFeature = cmLinkItem::DEFAULT; for (auto const& lib : libs) { @@ -1133,6 +1135,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( std::string const& config, cmOptionalLinkImplementation& impl, UseTo usage) const { + cm::GenEx::Context context(this->LocalGenerator, config, + this->LinkerLanguage); cmLocalGenerator const* lg = this->LocalGenerator; cmMakefile const* mf = lg->GetMakefile(); cmBTStringRange entryRange = this->Target->GetLinkImplementationEntries(); @@ -1145,8 +1149,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( "LINK_LIBRARIES", nullptr, nullptr, - this->LocalGenerator, - config, + context.LG, + context.Config, cmListFileBacktrace(), cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes, }; @@ -1169,8 +1173,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); std::string const& evaluated = - cge->Evaluate(this->LocalGenerator, config, this, &dagChecker, nullptr, - this->LinkerLanguage); + cge->Evaluate(context.LG, context.Config, this, &dagChecker, nullptr, + context.Language); cmList llibs(evaluated); if (cge->GetHadHeadSensitiveCondition()) { impl.HadHeadSensitiveCondition = true; diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index 4846d6ffa1..8360dbe72f 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -14,6 +14,7 @@ #include #include "cmEvaluatedTargetProperty.h" +#include "cmGenExContext.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmLinkItem.h" #include "cmList.h" @@ -122,8 +123,10 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( std::vector> result; std::unordered_set uniqueDirectories; + cm::GenEx::Context context(this->LocalGenerator, config, language); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config, + this, "LINK_DIRECTORIES", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -136,11 +139,11 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( this, config, language, &dagChecker, this->LinkDirectoriesEntries); - AddInterfaceEntries(this, config, "INTERFACE_LINK_DIRECTORIES", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, - this->GetPolicyStatusCMP0099() == cmPolicies::NEW - ? UseTo::Link - : UseTo::Compile); + AddInterfaceEntries( + this, context.Config, "INTERFACE_LINK_DIRECTORIES", context.Language, + &dagChecker, entries, IncludeRuntimeInterface::Yes, + this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link + : UseTo::Compile); processLinkDirectories(this, entries, result, uniqueDirectories, debugDirectories); diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index 63baa1d544..ec623f6a51 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -18,6 +18,7 @@ #include #include "cmEvaluatedTargetProperty.h" +#include "cmGenExContext.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmList.h" #include "cmListFileCache.h" @@ -230,8 +231,10 @@ std::vector> cmGeneratorTarget::GetCompileOptions( std::vector> result; std::unordered_set uniqueOptions; + cm::GenEx::Context context(this->LocalGenerator, config, language); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config, + this, "COMPILE_OPTIONS", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -241,11 +244,13 @@ std::vector> cmGeneratorTarget::GetCompileOptions( this->DebugCompileOptionsDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->CompileOptionsEntries); + EvaluatedTargetPropertyEntries entries = + EvaluateTargetPropertyEntries(this, context.Config, context.Language, + &dagChecker, this->CompileOptionsEntries); - AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, context.Config, "INTERFACE_COMPILE_OPTIONS", + context.Language, &dagChecker, entries, + IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueOptions, debugOptions, "compile options", OptionsParse::Shell); @@ -270,8 +275,11 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( std::vector> result; std::unordered_set uniqueFeatures; + cm::GenEx::Context context(this->LocalGenerator, config, + /*language=*/std::string()); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config, + this, "COMPILE_FEATURES", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -281,11 +289,12 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( this->DebugCompileFeaturesDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, std::string(), &dagChecker, this->CompileFeaturesEntries); + EvaluatedTargetPropertyEntries entries = + EvaluateTargetPropertyEntries(this, context.Config, context.Language, + &dagChecker, this->CompileFeaturesEntries); - AddInterfaceEntries(this, config, "INTERFACE_COMPILE_FEATURES", - std::string(), &dagChecker, entries, + AddInterfaceEntries(this, context.Config, "INTERFACE_COMPILE_FEATURES", + context.Language, &dagChecker, entries, IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueFeatures, debugFeatures, @@ -319,9 +328,10 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( std::vector> list; std::unordered_set uniqueOptions; + cm::GenEx::Context context(this->LocalGenerator, config, language); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "COMPILE_DEFINITIONS", nullptr, - nullptr, this->LocalGenerator, config, + this, "COMPILE_DEFINITIONS", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -332,10 +342,12 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( this->DebugCompileDefinitionsDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->CompileDefinitionsEntries); + this, context.Config, context.Language, &dagChecker, + this->CompileDefinitionsEntries); - AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, context.Config, "INTERFACE_COMPILE_DEFINITIONS", + context.Language, &dagChecker, entries, + IncludeRuntimeInterface::Yes); processOptions(this, entries, list, uniqueOptions, debugDefines, "compile definitions", OptionsParse::None); @@ -356,8 +368,10 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( } std::unordered_set uniqueOptions; + cm::GenEx::Context context(this->LocalGenerator, config, language); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "PRECOMPILE_HEADERS", nullptr, nullptr, this->LocalGenerator, config, + this, "PRECOMPILE_HEADERS", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -368,11 +382,13 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( this->DebugPrecompileHeadersDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->PrecompileHeadersEntries); + EvaluatedTargetPropertyEntries entries = + EvaluateTargetPropertyEntries(this, context.Config, context.Language, + &dagChecker, this->PrecompileHeadersEntries); - AddInterfaceEntries(this, config, "INTERFACE_PRECOMPILE_HEADERS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, context.Config, "INTERFACE_PRECOMPILE_HEADERS", + context.Language, &dagChecker, entries, + IncludeRuntimeInterface::Yes); std::vector> list; processOptions(this, entries, list, uniqueOptions, debugDefines, @@ -413,8 +429,10 @@ std::vector> cmGeneratorTarget::GetLinkOptions( std::vector> result; std::unordered_set uniqueOptions; + cm::GenEx::Context context(this->LocalGenerator, config, language); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config, + this, "LINK_OPTIONS", nullptr, nullptr, context.LG, context.Config, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -424,14 +442,15 @@ std::vector> cmGeneratorTarget::GetLinkOptions( this->DebugLinkOptionsDone = true; - EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->LinkOptionsEntries); + EvaluatedTargetPropertyEntries entries = + EvaluateTargetPropertyEntries(this, context.Config, context.Language, + &dagChecker, this->LinkOptionsEntries); - AddInterfaceEntries(this, config, "INTERFACE_LINK_OPTIONS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, - this->GetPolicyStatusCMP0099() == cmPolicies::NEW - ? UseTo::Link - : UseTo::Compile); + AddInterfaceEntries( + this, context.Config, "INTERFACE_LINK_OPTIONS", context.Language, + &dagChecker, entries, IncludeRuntimeInterface::Yes, + this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link + : UseTo::Compile); processOptions(this, entries, result, uniqueOptions, debugOptions, "link options", OptionsParse::Shell, this->IsDeviceLink()); @@ -595,9 +614,11 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( std::vector> result; std::unordered_set uniqueOptions; + cm::GenEx::Context context(this->LocalGenerator, config, language); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "STATIC_LIBRARY_OPTIONS", nullptr, - nullptr, this->LocalGenerator, config, + this, "STATIC_LIBRARY_OPTIONS", nullptr, nullptr, + context.LG, context.Config, }; EvaluatedTargetPropertyEntries entries; @@ -605,7 +626,7 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( std::unique_ptr entry = TargetPropertyEntry::Create( *this->LocalGenerator->GetCMakeInstance(), *linkOptions); entries.Entries.emplace_back(EvaluateTargetPropertyEntry( - this, config, language, &dagChecker, *entry)); + this, context.Config, context.Language, &dagChecker, *entry)); } processOptions(this, entries, result, uniqueOptions, false, "static library link options", OptionsParse::Shell); @@ -640,8 +661,9 @@ std::vector> cmGeneratorTarget::GetLinkDepends( { std::vector> result; std::unordered_set uniqueOptions; + cm::GenEx::Context context(this->LocalGenerator, config, language); cmGeneratorExpressionDAGChecker dagChecker{ - this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config, + this, "LINK_DEPENDS", nullptr, nullptr, context.LG, context.Config, }; EvaluatedTargetPropertyEntries entries; @@ -651,14 +673,14 @@ std::vector> cmGeneratorTarget::GetLinkDepends( std::unique_ptr entry = TargetPropertyEntry::Create( *this->LocalGenerator->GetCMakeInstance(), depend); entries.Entries.emplace_back(EvaluateTargetPropertyEntry( - this, config, language, &dagChecker, *entry)); + this, context.Config, context.Language, &dagChecker, *entry)); } } - AddInterfaceEntries(this, config, "INTERFACE_LINK_DEPENDS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, - this->GetPolicyStatusCMP0099() == cmPolicies::NEW - ? UseTo::Link - : UseTo::Compile); + AddInterfaceEntries( + this, context.Config, "INTERFACE_LINK_DEPENDS", context.Language, + &dagChecker, entries, IncludeRuntimeInterface::Yes, + this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link + : UseTo::Compile); processOptions(this, entries, result, uniqueOptions, false, "link depends", OptionsParse::None); diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index fa27998ae3..586c8c01eb 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -24,6 +24,7 @@ #include "cmAlgorithms.h" #include "cmEvaluatedTargetProperty.h" #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmGlobalGenerator.h" @@ -84,9 +85,11 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget, cmFileSet const* fileSet, EvaluatedTargetPropertyEntries& entries) { + cm::GenEx::Context context(headTarget->GetLocalGenerator(), config, + /*language=*/std::string()); auto dirCges = fileSet->CompileDirectoryEntries(); auto dirs = fileSet->EvaluateDirectoryEntries( - dirCges, headTarget->GetLocalGenerator(), config, headTarget, dagChecker); + dirCges, context.LG, context.Config, headTarget, dagChecker); bool contextSensitiveDirs = false; for (auto const& dirCge : dirCges) { if (dirCge->GetHadContextSensitiveCondition()) { @@ -98,8 +101,8 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget, for (auto& entryCge : fileSet->CompileFileEntries()) { auto tpe = cmGeneratorTarget::TargetPropertyEntry::CreateFileSet( dirs, contextSensitiveDirs, std::move(entryCge), fileSet); - entries.Entries.emplace_back( - EvaluateTargetPropertyEntry(headTarget, config, "", dagChecker, *tpe)); + entries.Entries.emplace_back(EvaluateTargetPropertyEntry( + headTarget, context.Config, context.Language, dagChecker, *tpe)); EvaluatedTargetPropertyEntry const& entry = entries.Entries.back(); for (auto const& file : entry.Values) { auto* sf = headTarget->Makefile->GetOrCreateSource(file); @@ -240,12 +243,15 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( this->DebugSourcesDone = true; + cm::GenEx::Context context(this->LocalGenerator, config, + /*language=*/std::string()); + cmGeneratorExpressionDAGChecker dagChecker{ - this, "SOURCES", nullptr, nullptr, this->LocalGenerator, config, + this, "SOURCES", nullptr, nullptr, context.LG, context.Config, }; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, std::string(), &dagChecker, this->SourceEntries); + this, context.Config, context.Language, &dagChecker, this->SourceEntries); std::unordered_set uniqueSrcs; bool contextDependentDirectSources = @@ -253,9 +259,9 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( // Collect INTERFACE_SOURCES of all direct link-dependencies. EvaluatedTargetPropertyEntries linkInterfaceSourcesEntries; - AddInterfaceEntries(this, config, "INTERFACE_SOURCES", std::string(), - &dagChecker, linkInterfaceSourcesEntries, - IncludeRuntimeInterface::No, UseTo::Compile); + AddInterfaceEntries( + this, context.Config, "INTERFACE_SOURCES", context.Language, &dagChecker, + linkInterfaceSourcesEntries, IncludeRuntimeInterface::No, UseTo::Compile); bool contextDependentInterfaceSources = processSources( this, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources); @@ -263,7 +269,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( bool contextDependentObjects = false; if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) { EvaluatedTargetPropertyEntries linkObjectsEntries; - AddObjectEntries(this, config, &dagChecker, linkObjectsEntries); + AddObjectEntries(this, context.Config, &dagChecker, linkObjectsEntries); contextDependentObjects = processSources(this, linkObjectsEntries, files, uniqueSrcs, debugSources); // Note that for imported targets or multi-config generators supporting @@ -274,7 +280,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( // Collect this target's file sets. EvaluatedTargetPropertyEntries fileSetEntries; - AddFileSetEntries(this, config, &dagChecker, fileSetEntries); + AddFileSetEntries(this, context.Config, &dagChecker, fileSetEntries); bool contextDependentFileSets = processSources(this, fileSetEntries, files, uniqueSrcs, debugSources); diff --git a/Source/cmInstallFileSetGenerator.cxx b/Source/cmInstallFileSetGenerator.cxx index e92f4299d7..1331661872 100644 --- a/Source/cmInstallFileSetGenerator.cxx +++ b/Source/cmInstallFileSetGenerator.cxx @@ -12,6 +12,7 @@ #include #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -122,14 +123,16 @@ cmInstallFileSetGenerator::CalculateFilesPerDir( { std::map> result; + cm::GenEx::Context context(this->LocalGenerator, config); + auto dirCges = this->FileSet->CompileDirectoryEntries(); auto dirs = this->FileSet->EvaluateDirectoryEntries( - dirCges, this->LocalGenerator, config, this->Target); + dirCges, context.LG, context.Config, this->Target); auto fileCges = this->FileSet->CompileFileEntries(); for (auto const& fileCge : fileCges) { - this->FileSet->EvaluateFileEntry( - dirs, result, fileCge, this->LocalGenerator, config, this->Target); + this->FileSet->EvaluateFileEntry(dirs, result, fileCge, context.LG, + context.Config, this->Target); } return result; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5187f5ed1a..73fed489d5 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -23,6 +23,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmFileSet.h" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorOptions.h" @@ -205,6 +206,7 @@ void cmMakefileTargetGenerator::CreateRuleFile() void cmMakefileTargetGenerator::WriteTargetBuildRules() { + cm::GenEx::Context context(this->LocalGenerator, this->GetConfigName()); this->GeneratorTarget->CheckCxxModuleStatus(this->GetConfigName()); // -- Write the custom commands for this target @@ -362,14 +364,12 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() auto fileEntries = file_set->CompileFileEntries(); auto directoryEntries = file_set->CompileDirectoryEntries(); auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, this->LocalGenerator, this->GetConfigName(), - this->GeneratorTarget); + directoryEntries, context.LG, context.Config, this->GeneratorTarget); std::map> files; for (auto const& entry : fileEntries) { - file_set->EvaluateFileEntry(directories, files, entry, - this->LocalGenerator, this->GetConfigName(), - this->GeneratorTarget); + file_set->EvaluateFileEntry(directories, files, entry, context.LG, + context.Config, this->GeneratorTarget); } for (auto const& it : files) { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 36d75afeb1..a7bbc8c16a 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -31,6 +31,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmEvaluatedTargetProperty.h" +#include "cmGenExContext.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" @@ -1966,24 +1967,26 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() if (this->MultiConfig) { for (auto const& cfg : this->ConfigsList) { if (!cfg.empty()) { + cm::GenEx::Context context(this->LocalGen, cfg, "CXX"); cmGeneratorExpressionDAGChecker dagChecker{ - this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, - nullptr, this->LocalGen, cfg, + this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, + context.LG, context.Config, }; - AddInterfaceEntries(this->GenTarget, cfg, - "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", - &dagChecker, InterfaceAutoMocMacroNamesEntries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries( + this->GenTarget, context.Config, "INTERFACE_AUTOMOC_MACRO_NAMES", + context.Language, &dagChecker, InterfaceAutoMocMacroNamesEntries, + IncludeRuntimeInterface::Yes); } } } else { + cm::GenEx::Context context(this->LocalGen, this->ConfigDefault, "CXX"); cmGeneratorExpressionDAGChecker dagChecker{ - this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, - nullptr, this->LocalGen, this->ConfigDefault, + this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, + context.LG, context.Config, }; - AddInterfaceEntries(this->GenTarget, this->ConfigDefault, - "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker, - InterfaceAutoMocMacroNamesEntries, + AddInterfaceEntries(this->GenTarget, context.Config, + "INTERFACE_AUTOMOC_MACRO_NAMES", context.Language, + &dagChecker, InterfaceAutoMocMacroNamesEntries, IncludeRuntimeInterface::Yes); } From 1735b0d147db2caac7902237c705d6de04672bd0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 21 Sep 2025 14:26:55 -0400 Subject: [PATCH 2/3] 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. --- Source/cmCommonTargetGenerator.cxx | 7 +++---- Source/cmComputeLinkDepends.cxx | 18 ++++-------------- Source/cmExportTryCompileFileGenerator.cxx | 4 ++-- Source/cmGeneratorExpression.cxx | 3 +-- Source/cmGeneratorExpressionDAGChecker.cxx | 8 ++++---- Source/cmGeneratorExpressionDAGChecker.h | 5 ++--- Source/cmGeneratorExpressionNode.cxx | 8 +++----- Source/cmGeneratorTarget.cxx | 7 +++---- .../cmGeneratorTarget_IncludeDirectories.cxx | 14 ++++---------- Source/cmGeneratorTarget_Link.cxx | 6 ++---- Source/cmGeneratorTarget_LinkDirectories.cxx | 3 +-- Source/cmGeneratorTarget_Options.cxx | 15 +++++++-------- Source/cmGeneratorTarget_Sources.cxx | 2 +- .../cmGeneratorTarget_TransitiveProperty.cxx | 8 +------- Source/cmQtAutoGenInitializer.cxx | 6 ++---- 15 files changed, 40 insertions(+), 74 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 616975019e..3da4657ef6 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -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); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index adb4be5aa3..a7a64326ab 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -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, diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index ac9cfbbdc4..e90295b20f 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -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( - 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 cge = ge.Parse(*prop); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index cba6049bdb..62c14397dc 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -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( diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 0a548dcadf..c7e71f7c78 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -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(); } diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 03492c5edf..c310c8e6b3 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -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); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a085eb44f6..d5f59840a4 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -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()) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 276af84778..c57abc398c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -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& 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), diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index 1e1bd15734..8c8382c4ee 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -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> 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( diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index 370d4711de..f33d4c8652 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -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, }; diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index 8360dbe72f..693af0d6b8 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -124,9 +124,8 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( std::unordered_set 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( diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index ec623f6a51..aad968d12e 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -234,7 +234,7 @@ std::vector> 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> 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> 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> 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> 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> 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> cmGeneratorTarget::GetLinkDepends( std::unordered_set 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; diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index 586c8c01eb..25d8b2d7d0 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -247,7 +247,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( /*language=*/std::string()); cmGeneratorExpressionDAGChecker dagChecker{ - this, "SOURCES", nullptr, nullptr, context.LG, context.Config, + this, "SOURCES", nullptr, nullptr, context, }; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index cce4e43426..a6ab68c2d3 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -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: diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a7bbc8c16a..7343edcc54 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -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, From 77570a1ac173a59031b608ddf63d921b2b2f3396 Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 21 Sep 2025 15:37:53 -0400 Subject: [PATCH 3/3] GenEx: Consolidate target property evaluation context arguments --- Source/cmDyndepCollation.cxx | 8 +-- Source/cmEvaluatedTargetProperty.cxx | 46 ++++++------ Source/cmEvaluatedTargetProperty.h | 18 +++-- Source/cmExportBuildCMakeConfigGenerator.cxx | 11 ++- .../cmExportInstallCMakeConfigGenerator.cxx | 7 +- Source/cmExportTryCompileFileGenerator.cxx | 3 +- Source/cmFileAPICodemodel.cxx | 14 ++-- Source/cmFileSet.cxx | 21 +++--- Source/cmFileSet.h | 13 ++-- Source/cmGeneratorExpression.cxx | 26 ++++--- Source/cmGeneratorExpression.h | 15 +++- .../cmGeneratorExpressionEvaluationFile.cxx | 24 +++---- Source/cmGeneratorExpressionEvaluationFile.h | 12 ++-- Source/cmGeneratorExpressionNode.cxx | 3 +- Source/cmGeneratorTarget.cxx | 14 ++-- Source/cmGeneratorTarget.h | 7 +- .../cmGeneratorTarget_IncludeDirectories.cxx | 8 +-- Source/cmGeneratorTarget_Link.cxx | 7 +- Source/cmGeneratorTarget_LinkDirectories.cxx | 12 ++-- Source/cmGeneratorTarget_Options.cxx | 71 ++++++++----------- Source/cmGeneratorTarget_Sources.cxx | 38 +++++----- .../cmGeneratorTarget_TargetPropertyEntry.cxx | 31 ++++---- Source/cmInstallFileSetGenerator.cxx | 8 +-- Source/cmMakefileTargetGenerator.cxx | 6 +- Source/cmQtAutoGenInitializer.cxx | 15 ++-- 25 files changed, 218 insertions(+), 220 deletions(-) diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx index bc79df5832..7f8a9b86ea 100644 --- a/Source/cmDyndepCollation.cxx +++ b/Source/cmDyndepCollation.cxx @@ -110,12 +110,12 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt, auto fileEntries = file_set->CompileFileEntries(); auto directoryEntries = file_set->CompileDirectoryEntries(); - auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, gt); + auto directories = + file_set->EvaluateDirectoryEntries(directoryEntries, context, gt); std::map> files_per_dirs; for (auto const& entry : fileEntries) { - file_set->EvaluateFileEntry(directories, files_per_dirs, entry, - context.LG, context.Config, gt); + file_set->EvaluateFileEntry(directories, files_per_dirs, entry, context, + gt); } Json::Value fs_dest = Json::nullValue; diff --git a/Source/cmEvaluatedTargetProperty.cxx b/Source/cmEvaluatedTargetProperty.cxx index c09f79b0ae..7112a9ba69 100644 --- a/Source/cmEvaluatedTargetProperty.cxx +++ b/Source/cmEvaluatedTargetProperty.cxx @@ -21,14 +21,12 @@ EvaluatedTargetPropertyEntry::EvaluatedTargetPropertyEntry( } EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* thisTarget, cm::GenEx::Context const& context, + cmGeneratorExpressionDAGChecker* dagChecker, cmGeneratorTarget::TargetPropertyEntry& entry) { EvaluatedTargetPropertyEntry ee(entry.LinkImplItem, entry.GetBacktrace()); - cmExpandList(entry.Evaluate(thisTarget->GetLocalGenerator(), config, - thisTarget, dagChecker, lang), - ee.Values); + cmExpandList(entry.Evaluate(context, thisTarget, dagChecker), ee.Values); if (entry.GetHadContextSensitiveCondition()) { ee.ContextDependent = true; } @@ -36,24 +34,24 @@ EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( } EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* thisTarget, cm::GenEx::Context const& context, + cmGeneratorExpressionDAGChecker* dagChecker, std::vector> const& in) { EvaluatedTargetPropertyEntries out; out.Entries.reserve(in.size()); for (auto const& entry : in) { - out.Entries.emplace_back(EvaluateTargetPropertyEntry( - thisTarget, config, lang, dagChecker, *entry)); + out.Entries.emplace_back( + EvaluateTargetPropertyEntry(thisTarget, context, dagChecker, *entry)); } return out; } namespace { void addInterfaceEntry(cmGeneratorTarget const* headTarget, - std::string const& config, std::string const& prop, - std::string const& lang, + std::string const& prop, + cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, EvaluatedTargetPropertyEntries& entries, cmGeneratorTarget::UseTo usage, @@ -65,9 +63,8 @@ void addInterfaceEntry(cmGeneratorTarget const* headTarget, // Pretend $ appeared in our // caller's property and hand-evaluate it as if it were compiled. // Create a context as cmCompiledGeneratorExpression::Evaluate does. - cm::GenEx::Evaluation eval( - cm::GenEx::Context(headTarget->GetLocalGenerator(), config, lang), - false, headTarget, headTarget, true, lib.Backtrace); + cm::GenEx::Evaluation eval(context, false, headTarget, headTarget, true, + lib.Backtrace); cmExpandList( lib.Target->EvaluateInterfaceProperty(prop, &eval, dagChecker, usage), ee.Values); @@ -79,8 +76,8 @@ void addInterfaceEntry(cmGeneratorTarget const* headTarget, } void AddInterfaceEntries(cmGeneratorTarget const* headTarget, - std::string const& config, std::string const& prop, - std::string const& lang, + std::string const& prop, + cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, EvaluatedTargetPropertyEntries& entries, IncludeRuntimeInterface searchRuntime, @@ -88,25 +85,26 @@ void AddInterfaceEntries(cmGeneratorTarget const* headTarget, { if (searchRuntime == IncludeRuntimeInterface::Yes) { if (cmLinkImplementation const* impl = - headTarget->GetLinkImplementation(config, usage)) { + headTarget->GetLinkImplementation(context.Config, usage)) { entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition; - auto runtimeLibIt = impl->LanguageRuntimeLibraries.find(lang); + auto runtimeLibIt = + impl->LanguageRuntimeLibraries.find(context.Language); if (runtimeLibIt != impl->LanguageRuntimeLibraries.end()) { - addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, + addInterfaceEntry(headTarget, prop, context, dagChecker, entries, usage, runtimeLibIt->second); } - addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, - usage, impl->Libraries); + addInterfaceEntry(headTarget, prop, context, dagChecker, entries, usage, + impl->Libraries); } } else { if (cmLinkImplementationLibraries const* impl = - headTarget->GetLinkImplementationLibraries(config, usage)) { + headTarget->GetLinkImplementationLibraries(context.Config, usage)) { entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition; - addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, - usage, impl->Libraries); + addInterfaceEntry(headTarget, prop, context, dagChecker, entries, usage, + impl->Libraries); } } } diff --git a/Source/cmEvaluatedTargetProperty.h b/Source/cmEvaluatedTargetProperty.h index f9cdada00a..4ab4af48cd 100644 --- a/Source/cmEvaluatedTargetProperty.h +++ b/Source/cmEvaluatedTargetProperty.h @@ -9,6 +9,12 @@ #include "cmGeneratorTarget.h" #include "cmListFileCache.h" +namespace cm { +namespace GenEx { +struct Context; +} +} + class cmLinkImplItem; struct cmGeneratorExpressionDAGChecker; @@ -34,8 +40,8 @@ struct EvaluatedTargetPropertyEntry }; EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* thisTarget, cm::GenEx::Context const& context, + cmGeneratorExpressionDAGChecker* dagChecker, cmGeneratorTarget::TargetPropertyEntry& entry); struct EvaluatedTargetPropertyEntries @@ -45,8 +51,8 @@ struct EvaluatedTargetPropertyEntries }; EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* thisTarget, cm::GenEx::Context const& context, + cmGeneratorExpressionDAGChecker* dagChecker, std::vector> const& in); @@ -71,8 +77,8 @@ enum class IncludeRuntimeInterface }; void AddInterfaceEntries( - cmGeneratorTarget const* headTarget, std::string const& config, - std::string const& prop, std::string const& lang, + cmGeneratorTarget const* headTarget, std::string const& prop, + cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, EvaluatedTargetPropertyEntries& entries, IncludeRuntimeInterface searchRuntime, diff --git a/Source/cmExportBuildCMakeConfigGenerator.cxx b/Source/cmExportBuildCMakeConfigGenerator.cxx index e66e88f8fc..d317ffd2d2 100644 --- a/Source/cmExportBuildCMakeConfigGenerator.cxx +++ b/Source/cmExportBuildCMakeConfigGenerator.cxx @@ -178,8 +178,8 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetDirectories( for (auto const& config : configs) { cm::GenEx::Context context(gte->LocalGenerator, config); - auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, gte); + auto directories = + fileSet->EvaluateDirectoryEntries(directoryEntries, context, gte); bool const contextSensitive = std::any_of(directoryEntries.begin(), directoryEntries.end(), @@ -229,13 +229,12 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetFiles( for (auto const& config : configs) { cm::GenEx::Context context(gte->LocalGenerator, config); - auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, gte); + auto directories = + fileSet->EvaluateDirectoryEntries(directoryEntries, context, gte); std::map> files; for (auto const& entry : fileEntries) { - fileSet->EvaluateFileEntry(directories, files, entry, context.LG, - context.Config, gte); + fileSet->EvaluateFileEntry(directories, files, entry, context, gte); } bool const contextSensitive = diff --git a/Source/cmExportInstallCMakeConfigGenerator.cxx b/Source/cmExportInstallCMakeConfigGenerator.cxx index 7ebeb723ff..a039be48dc 100644 --- a/Source/cmExportInstallCMakeConfigGenerator.cxx +++ b/Source/cmExportInstallCMakeConfigGenerator.cxx @@ -341,13 +341,12 @@ std::string cmExportInstallCMakeConfigGenerator::GetFileSetFiles( for (auto const& config : configs) { cm::GenEx::Context context(gte->LocalGenerator, config); - auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, gte); + auto directories = + fileSet->EvaluateDirectoryEntries(directoryEntries, context, gte); std::map> files; for (auto const& entry : fileEntries) { - fileSet->EvaluateFileEntry(directories, files, entry, context.LG, - context.Config, gte); + fileSet->EvaluateFileEntry(directories, files, entry, context, gte); } auto unescapedDest = destCge->Evaluate(gte->LocalGenerator, config, gte); auto dest = diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index e90295b20f..20c0714a43 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -100,8 +100,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = cge->Evaluate(context.LG, context.Config, &gDummyHead, - &dagChecker, tgt, context.Language); + std::string result = cge->Evaluate(context, &dagChecker, &gDummyHead, tgt); std::set const& allTargets = cge->GetAllTargetsSeen(); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 240c96bf44..eb1cb6c2c4 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -1084,14 +1084,12 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) cm::GenEx::Context context(target->LocalGenerator, this->Config); auto dirCges = fileSet->CompileDirectoryEntries(); - auto dirs = fileSet->EvaluateDirectoryEntries(dirCges, context.LG, - context.Config, target); + auto dirs = fileSet->EvaluateDirectoryEntries(dirCges, context, target); auto entryCges = fileSet->CompileFileEntries(); std::map> entries; for (auto const& entryCge : entryCges) { - fileSet->EvaluateFileEntry(dirs, entries, entryCge, context.LG, - context.Config, target); + fileSet->EvaluateFileEntry(dirs, entries, entryCge, context, target); } Json::Value files = Json::arrayValue; @@ -1615,15 +1613,15 @@ std::pair Target::DumpFileSets() auto fileEntries = fs->CompileFileEntries(); auto directoryEntries = fs->CompileDirectoryEntries(); - auto directories = fs->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, this->GT); + auto directories = + fs->EvaluateDirectoryEntries(directoryEntries, context, this->GT); fsJson.append(this->DumpFileSet(fs, directories)); std::map> files_per_dirs; for (auto const& entry : fileEntries) { - fs->EvaluateFileEntry(directories, files_per_dirs, entry, context.LG, - context.Config, this->GT); + fs->EvaluateFileEntry(directories, files_per_dirs, entry, context, + this->GT); } for (auto const& files_per_dir : files_per_dirs) { diff --git a/Source/cmFileSet.cxx b/Source/cmFileSet.cxx index 6e10489536..3861d6171c 100644 --- a/Source/cmFileSet.cxx +++ b/Source/cmFileSet.cxx @@ -14,6 +14,7 @@ #include "cmsys/RegularExpression.hxx" +#include "cmGenExContext.h" #include "cmGeneratorExpression.h" #include "cmList.h" #include "cmListFileCache.h" @@ -156,8 +157,7 @@ cmFileSet::CompileDirectoryEntries() const std::vector cmFileSet::EvaluateDirectoryEntries( std::vector> const& cges, - cmLocalGenerator const* lg, std::string const& config, - cmGeneratorTarget const* target, + cm::GenEx::Context const& context, cmGeneratorTarget const* target, cmGeneratorExpressionDAGChecker* dagChecker) const { struct DirCacheEntry @@ -169,11 +169,11 @@ std::vector cmFileSet::EvaluateDirectoryEntries( std::unordered_map dirCache; std::vector result; for (auto const& cge : cges) { - auto entry = cge->Evaluate(lg, config, target, dagChecker); + auto entry = cge->Evaluate(context, dagChecker, target); cmList dirs{ entry }; for (std::string dir : dirs) { if (!cmSystemTools::FileIsFullPath(dir)) { - dir = cmStrCat(lg->GetCurrentSourceDirectory(), '/', dir); + dir = cmStrCat(context.LG->GetCurrentSourceDirectory(), '/', dir); } auto dirCacheResult = dirCache.emplace(dir, DirCacheEntry()); @@ -198,7 +198,7 @@ std::vector cmFileSet::EvaluateDirectoryEntries( priorDirCacheEntry.collapsedDir) || cmSystemTools::IsSubDirectory(priorDirCacheEntry.collapsedDir, dirCacheEntry.collapsedDir))) { - lg->GetCMakeInstance()->IssueMessage( + context.LG->GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, cmStrCat( "Base directories in file set cannot be subdirectories of each " @@ -218,14 +218,13 @@ void cmFileSet::EvaluateFileEntry( std::vector const& dirs, std::map>& filesPerDir, std::unique_ptr const& cge, - cmLocalGenerator const* lg, std::string const& config, - cmGeneratorTarget const* target, + cm::GenEx::Context const& context, cmGeneratorTarget const* target, cmGeneratorExpressionDAGChecker* dagChecker) const { - auto files = cge->Evaluate(lg, config, target, dagChecker); + auto files = cge->Evaluate(context, dagChecker, target); for (std::string file : cmList{ files }) { if (!cmSystemTools::FileIsFullPath(file)) { - file = cmStrCat(lg->GetCurrentSourceDirectory(), '/', file); + file = cmStrCat(context.LG->GetCurrentSourceDirectory(), '/', file); } auto collapsedFile = cmSystemTools::CollapseFullPath(file); bool found = false; @@ -246,8 +245,8 @@ void cmFileSet::EvaluateFileEntry( for (auto const& dir : dirs) { e << "\n " << dir; } - lg->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str(), - cge->GetBacktrace()); + context.LG->GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, e.str(), cge->GetBacktrace()); return; } diff --git a/Source/cmFileSet.h b/Source/cmFileSet.h index ac2fb78361..3b37bf8c9b 100644 --- a/Source/cmFileSet.h +++ b/Source/cmFileSet.h @@ -12,10 +12,15 @@ #include "cmListFileCache.h" +namespace cm { +namespace GenEx { +struct Context; +} +} + class cmCompiledGeneratorExpression; struct cmGeneratorExpressionDAGChecker; class cmGeneratorTarget; -class cmLocalGenerator; class cmMakefile; class cmake; @@ -67,16 +72,14 @@ public: std::vector EvaluateDirectoryEntries( std::vector> const& cges, - cmLocalGenerator const* lg, std::string const& config, - cmGeneratorTarget const* target, + cm::GenEx::Context const& context, cmGeneratorTarget const* target, cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; void EvaluateFileEntry( std::vector const& dirs, std::map>& filesPerDir, std::unique_ptr const& cge, - cmLocalGenerator const* lg, std::string const& config, - cmGeneratorTarget const* target, + cm::GenEx::Context const& context, cmGeneratorTarget const* target, cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; static bool IsValidName(std::string const& name); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 62c14397dc..031935a950 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -55,22 +55,29 @@ std::string cmGeneratorExpression::Evaluate( "genex_compile_eval", input); #endif + cm::GenEx::Context context(lg, config, language); cmCompiledGeneratorExpression cge(*lg->GetCMakeInstance(), cmListFileBacktrace(), std::move(input)); - return cge.Evaluate(lg, config, headTarget, dagChecker, currentTarget, - language); + return cge.Evaluate(context, dagChecker, headTarget, currentTarget); } return input; } std::string const& cmCompiledGeneratorExpression::Evaluate( cmLocalGenerator const* lg, std::string const& config, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - cmGeneratorTarget const* currentTarget, std::string const& language) const + cmGeneratorTarget const* headTarget) const { - cm::GenEx::Evaluation eval(cm::GenEx::Context(lg, config, language), - this->Quiet, headTarget, + cm::GenEx::Context context(lg, config); + return this->Evaluate(context, nullptr, headTarget); +} + +std::string const& cmCompiledGeneratorExpression::Evaluate( + cm::GenEx::Context const& context, + cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* headTarget, + cmGeneratorTarget const* currentTarget) const +{ + cm::GenEx::Evaluation eval(context, this->Quiet, headTarget, currentTarget ? currentTarget : headTarget, this->EvaluateForBuildsystem, this->Backtrace); @@ -466,7 +473,6 @@ std::string const& cmGeneratorExpressionInterpreter::Evaluate( context, }; - return this->CompiledGeneratorExpression->Evaluate( - context.LG, context.Config, this->HeadTarget, &dagChecker, nullptr, - context.Language); + return this->CompiledGeneratorExpression->Evaluate(context, &dagChecker, + this->HeadTarget); } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index e5269b1d99..1389144d36 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -16,6 +16,12 @@ #include "cmListFileCache.h" #include "cmLocalGenerator.h" +namespace cm { +namespace GenEx { +struct Context; +} +} + class cmake; class cmCompiledGeneratorExpression; class cmGeneratorTarget; @@ -104,10 +110,13 @@ public: std::string const& Evaluate( cmLocalGenerator const* lg, std::string const& config, + cmGeneratorTarget const* headTarget = nullptr) const; + + std::string const& Evaluate( + cm::GenEx::Context const& context, + cmGeneratorExpressionDAGChecker* dagChecker, cmGeneratorTarget const* headTarget = nullptr, - cmGeneratorExpressionDAGChecker* dagChecker = nullptr, - cmGeneratorTarget const* currentTarget = nullptr, - std::string const& language = std::string()) const; + cmGeneratorTarget const* currentTarget = nullptr) const; /** Get set of targets found during evaluations. */ std::set const& GetTargets() const diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index d1c352fe97..7909fc0c42 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -44,8 +44,8 @@ void cmGeneratorExpressionEvaluationFile::Generate( std::string rawCondition = this->Condition->GetInput(); cmGeneratorTarget* target = lg->FindGeneratorTargetToUse(this->Target); if (!rawCondition.empty()) { - std::string condResult = this->Condition->Evaluate( - context.LG, context.Config, target, nullptr, nullptr, context.Language); + std::string condResult = + this->Condition->Evaluate(context, nullptr, target); if (condResult == "0") { return; } @@ -60,10 +60,9 @@ void cmGeneratorExpressionEvaluationFile::Generate( } } - std::string const outputFileName = this->GetOutputFileName( - context.LG, target, context.Config, context.Language); - std::string const& outputContent = inputExpression->Evaluate( - context.LG, context.Config, target, nullptr, nullptr, context.Language); + std::string const outputFileName = this->GetOutputFileName(context, target); + std::string const& outputContent = + inputExpression->Evaluate(context, nullptr, target); auto it = outputFiles.find(outputFileName); @@ -125,8 +124,9 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( cmGeneratorTarget* target = lg->FindGeneratorTargetToUse(this->Target); gg->GetEnabledLanguages(enabledLanguages); - for (std::string const& le : enabledLanguages) { - std::string const name = this->GetOutputFileName(lg, target, config, le); + for (std::string const& lang : enabledLanguages) { + cm::GenEx::Context context(lg, config, lang); + std::string const name = this->GetOutputFileName(context, target); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateGeneratedSource(name); // Tell the build system generators that there is no build rule @@ -206,12 +206,10 @@ std::string cmGeneratorExpressionEvaluationFile::GetInputFileName( } std::string cmGeneratorExpressionEvaluationFile::GetOutputFileName( - cmLocalGenerator const* lg, cmGeneratorTarget* target, - std::string const& config, std::string const& lang) + cm::GenEx::Context const& context, cmGeneratorTarget* target) { - cm::GenEx::Context context(lg, config, lang); - std::string outputFileName = this->OutputFileExpr->Evaluate( - context.LG, context.Config, target, nullptr, nullptr, context.Language); + std::string outputFileName = + this->OutputFileExpr->Evaluate(context, nullptr, target); if (cmSystemTools::FileIsFullPath(outputFileName)) { outputFileName = cmSystemTools::CollapseFullPath(outputFileName); diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index abe1e2319d..dab5f14ff9 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -14,6 +14,12 @@ #include "cmGeneratorExpression.h" #include "cmPolicies.h" +namespace cm { +namespace GenEx { +struct Context; +} +} + class cmGeneratorTarget; class cmLocalGenerator; @@ -40,10 +46,8 @@ private: std::map& outputFiles, mode_t perm); std::string GetInputFileName(cmLocalGenerator const* lg); - std::string GetOutputFileName(cmLocalGenerator const* lg, - cmGeneratorTarget* target, - std::string const& config, - std::string const& lang); + std::string GetOutputFileName(cm::GenEx::Context const& context, + cmGeneratorTarget* target); enum PathRole { PathForInput, diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index d5f59840a4..183d3cb019 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -64,8 +64,7 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression( cge->SetEvaluateForBuildsystem(eval->EvaluateForBuildsystem); cge->SetQuiet(eval->Quiet); std::string result = - cge->Evaluate(eval->Context.LG, eval->Context.Config, headTarget, - dagChecker, currentTarget, eval->Context.Language); + cge->Evaluate(eval->Context, dagChecker, headTarget, currentTarget); if (cge->GetHadContextSensitiveCondition()) { eval->HadContextSensitiveCondition = true; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c57abc398c..7a3f1dc599 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5445,16 +5445,15 @@ bool cmGeneratorTarget::AddHeaderSetVerification() cmMakefile::GeneratorConfigQuery::IncludeEmptyConfig)) { cm::GenEx::Context context(this->LocalGenerator, config); if (first || dirCgesContextSensitive) { - dirs = fileSet->EvaluateDirectoryEntries(dirCges, context.LG, - context.Config, this); + dirs = fileSet->EvaluateDirectoryEntries(dirCges, context, this); dirCgesContextSensitive = std::any_of(dirCges.begin(), dirCges.end(), contextSensitive); } if (first || fileCgesContextSensitive) { filesPerDir.clear(); for (auto const& fileCge : fileCges) { - fileSet->EvaluateFileEntry(dirs, filesPerDir, fileCge, context.LG, - context.Config, this); + fileSet->EvaluateFileEntry(dirs, filesPerDir, fileCge, context, + this); if (fileCge->GetHadContextSensitiveCondition()) { fileCgesContextSensitive = true; } @@ -5989,13 +5988,12 @@ void cmGeneratorTarget::BuildFileSetInfoCache(std::string const& config) const auto fileEntries = file_set->CompileFileEntries(); auto directoryEntries = file_set->CompileDirectoryEntries(); - auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, this); + auto directories = + file_set->EvaluateDirectoryEntries(directoryEntries, context, this); std::map> files; for (auto const& entry : fileEntries) { - file_set->EvaluateFileEntry(directories, files, entry, context.LG, - context.Config, this); + file_set->EvaluateFileEntry(directories, files, entry, context, this); } for (auto const& it : files) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ff1516a9f8..b31645a7cd 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -27,6 +27,7 @@ namespace cm { namespace GenEx { +struct Context; struct Evaluation; } } @@ -1543,10 +1544,8 @@ public: cmFileSet const* fileSet, cmLinkImplItem const& item = NoLinkImplItem); virtual std::string const& Evaluate( - cmLocalGenerator* lg, std::string const& config, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language) const = 0; + cm::GenEx::Context const& context, cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker) const = 0; virtual cmListFileBacktrace GetBacktrace() const = 0; virtual std::string const& GetInput() const = 0; diff --git a/Source/cmGeneratorTarget_IncludeDirectories.cxx b/Source/cmGeneratorTarget_IncludeDirectories.cxx index 8c8382c4ee..fb6b0c1396 100644 --- a/Source/cmGeneratorTarget_IncludeDirectories.cxx +++ b/Source/cmGeneratorTarget_IncludeDirectories.cxx @@ -237,8 +237,7 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( this->DebugIncludesDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context.Config, context.Language, &dagChecker, - this->IncludeDirectoriesEntries); + this, context, &dagChecker, this->IncludeDirectoriesEntries); if (lang == "Swift") { AddLangSpecificImplicitIncludeDirectories( @@ -265,9 +264,8 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( entries); } - AddInterfaceEntries(this, context.Config, "INTERFACE_INCLUDE_DIRECTORIES", - context.Language, &dagChecker, entries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, "INTERFACE_INCLUDE_DIRECTORIES", context, + &dagChecker, entries, IncludeRuntimeInterface::Yes); processIncludeDirectories(this, entries, includes, uniqueIncludes, debugIncludes); diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index f33d4c8652..4e43e6db9b 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -567,8 +567,7 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, entry.Backtrace); std::unique_ptr cge = ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); - cmList libs{ cge->Evaluate(context.LG, context.Config, headTarget, - &dagChecker, this, context.Language) }; + cmList libs{ cge->Evaluate(context, &dagChecker, headTarget, this) }; auto linkFeature = cmLinkItem::DEFAULT; for (auto const& lib : libs) { @@ -1170,9 +1169,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( std::unique_ptr const cge = ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); - std::string const& evaluated = - cge->Evaluate(context.LG, context.Config, this, &dagChecker, nullptr, - context.Language); + std::string const& evaluated = cge->Evaluate(context, &dagChecker, this); cmList llibs(evaluated); if (cge->GetHadHeadSensitiveCondition()) { impl.HadHeadSensitiveCondition = true; diff --git a/Source/cmGeneratorTarget_LinkDirectories.cxx b/Source/cmGeneratorTarget_LinkDirectories.cxx index 693af0d6b8..7b34b8f649 100644 --- a/Source/cmGeneratorTarget_LinkDirectories.cxx +++ b/Source/cmGeneratorTarget_LinkDirectories.cxx @@ -136,13 +136,13 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( this->DebugLinkDirectoriesDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->LinkDirectoriesEntries); + this, context, &dagChecker, this->LinkDirectoriesEntries); - AddInterfaceEntries( - this, context.Config, "INTERFACE_LINK_DIRECTORIES", context.Language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, - this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link - : UseTo::Compile); + AddInterfaceEntries(this, "INTERFACE_LINK_DIRECTORIES", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes, + this->GetPolicyStatusCMP0099() == cmPolicies::NEW + ? UseTo::Link + : UseTo::Compile); processLinkDirectories(this, entries, result, uniqueDirectories, debugDirectories); diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index aad968d12e..012e6457c7 100644 --- a/Source/cmGeneratorTarget_Options.cxx +++ b/Source/cmGeneratorTarget_Options.cxx @@ -244,13 +244,11 @@ std::vector> cmGeneratorTarget::GetCompileOptions( this->DebugCompileOptionsDone = true; - EvaluatedTargetPropertyEntries entries = - EvaluateTargetPropertyEntries(this, context.Config, context.Language, - &dagChecker, this->CompileOptionsEntries); + EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( + this, context, &dagChecker, this->CompileOptionsEntries); - AddInterfaceEntries(this, context.Config, "INTERFACE_COMPILE_OPTIONS", - context.Language, &dagChecker, entries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, "INTERFACE_COMPILE_OPTIONS", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueOptions, debugOptions, "compile options", OptionsParse::Shell); @@ -289,13 +287,11 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( this->DebugCompileFeaturesDone = true; - EvaluatedTargetPropertyEntries entries = - EvaluateTargetPropertyEntries(this, context.Config, context.Language, - &dagChecker, this->CompileFeaturesEntries); + EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( + this, context, &dagChecker, this->CompileFeaturesEntries); - AddInterfaceEntries(this, context.Config, "INTERFACE_COMPILE_FEATURES", - context.Language, &dagChecker, entries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, "INTERFACE_COMPILE_FEATURES", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueFeatures, debugFeatures, "compile features", OptionsParse::None); @@ -342,12 +338,10 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( this->DebugCompileDefinitionsDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context.Config, context.Language, &dagChecker, - this->CompileDefinitionsEntries); + this, context, &dagChecker, this->CompileDefinitionsEntries); - AddInterfaceEntries(this, context.Config, "INTERFACE_COMPILE_DEFINITIONS", - context.Language, &dagChecker, entries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, "INTERFACE_COMPILE_DEFINITIONS", context, + &dagChecker, entries, IncludeRuntimeInterface::Yes); processOptions(this, entries, list, uniqueOptions, debugDefines, "compile definitions", OptionsParse::None); @@ -382,13 +376,11 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( this->DebugPrecompileHeadersDone = true; - EvaluatedTargetPropertyEntries entries = - EvaluateTargetPropertyEntries(this, context.Config, context.Language, - &dagChecker, this->PrecompileHeadersEntries); + EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( + this, context, &dagChecker, this->PrecompileHeadersEntries); - AddInterfaceEntries(this, context.Config, "INTERFACE_PRECOMPILE_HEADERS", - context.Language, &dagChecker, entries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, "INTERFACE_PRECOMPILE_HEADERS", context, + &dagChecker, entries, IncludeRuntimeInterface::Yes); std::vector> list; processOptions(this, entries, list, uniqueOptions, debugDefines, @@ -442,15 +434,14 @@ std::vector> cmGeneratorTarget::GetLinkOptions( this->DebugLinkOptionsDone = true; - EvaluatedTargetPropertyEntries entries = - EvaluateTargetPropertyEntries(this, context.Config, context.Language, - &dagChecker, this->LinkOptionsEntries); + EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( + this, context, &dagChecker, this->LinkOptionsEntries); - AddInterfaceEntries( - this, context.Config, "INTERFACE_LINK_OPTIONS", context.Language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, - this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link - : UseTo::Compile); + AddInterfaceEntries(this, "INTERFACE_LINK_OPTIONS", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes, + this->GetPolicyStatusCMP0099() == cmPolicies::NEW + ? UseTo::Link + : UseTo::Compile); processOptions(this, entries, result, uniqueOptions, debugOptions, "link options", OptionsParse::Shell, this->IsDeviceLink()); @@ -624,8 +615,8 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( 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.Config, context.Language, &dagChecker, *entry)); + entries.Entries.emplace_back( + EvaluateTargetPropertyEntry(this, context, &dagChecker, *entry)); } processOptions(this, entries, result, uniqueOptions, false, "static library link options", OptionsParse::Shell); @@ -671,15 +662,15 @@ std::vector> cmGeneratorTarget::GetLinkDepends( for (auto const& depend : depends) { std::unique_ptr entry = TargetPropertyEntry::Create( *this->LocalGenerator->GetCMakeInstance(), depend); - entries.Entries.emplace_back(EvaluateTargetPropertyEntry( - this, context.Config, context.Language, &dagChecker, *entry)); + entries.Entries.emplace_back( + EvaluateTargetPropertyEntry(this, context, &dagChecker, *entry)); } } - AddInterfaceEntries( - this, context.Config, "INTERFACE_LINK_DEPENDS", context.Language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, - this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link - : UseTo::Compile); + AddInterfaceEntries(this, "INTERFACE_LINK_DEPENDS", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes, + this->GetPolicyStatusCMP0099() == cmPolicies::NEW + ? UseTo::Link + : UseTo::Compile); processOptions(this, entries, result, uniqueOptions, false, "link depends", OptionsParse::None); diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index 25d8b2d7d0..3c58c8152a 100644 --- a/Source/cmGeneratorTarget_Sources.cxx +++ b/Source/cmGeneratorTarget_Sources.cxx @@ -47,12 +47,13 @@ namespace { using UseTo = cmGeneratorTarget::UseTo; void AddObjectEntries(cmGeneratorTarget const* headTarget, - std::string const& config, + cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, EvaluatedTargetPropertyEntries& entries) { if (cmLinkImplementationLibraries const* impl = - headTarget->GetLinkImplementationLibraries(config, UseTo::Link)) { + headTarget->GetLinkImplementationLibraries(context.Config, + UseTo::Link)) { entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition; for (cmLinkImplItem const& lib : impl->Libraries) { if (lib.Target && @@ -67,8 +68,7 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, cge->SetEvaluateForBuildsystem(true); EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); - cmExpandList(cge->Evaluate(headTarget->GetLocalGenerator(), config, - headTarget, dagChecker), + cmExpandList(cge->Evaluate(context, dagChecker, headTarget), ee.Values); if (cge->GetHadContextSensitiveCondition()) { ee.ContextDependent = true; @@ -80,16 +80,14 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, } void addFileSetEntry(cmGeneratorTarget const* headTarget, - std::string const& config, + cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, cmFileSet const* fileSet, EvaluatedTargetPropertyEntries& entries) { - cm::GenEx::Context context(headTarget->GetLocalGenerator(), config, - /*language=*/std::string()); auto dirCges = fileSet->CompileDirectoryEntries(); - auto dirs = fileSet->EvaluateDirectoryEntries( - dirCges, context.LG, context.Config, headTarget, dagChecker); + auto dirs = fileSet->EvaluateDirectoryEntries(dirCges, context, headTarget, + dagChecker); bool contextSensitiveDirs = false; for (auto const& dirCge : dirCges) { if (dirCge->GetHadContextSensitiveCondition()) { @@ -101,8 +99,8 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget, for (auto& entryCge : fileSet->CompileFileEntries()) { auto tpe = cmGeneratorTarget::TargetPropertyEntry::CreateFileSet( dirs, contextSensitiveDirs, std::move(entryCge), fileSet); - entries.Entries.emplace_back(EvaluateTargetPropertyEntry( - headTarget, context.Config, context.Language, dagChecker, *tpe)); + entries.Entries.emplace_back( + EvaluateTargetPropertyEntry(headTarget, context, dagChecker, *tpe)); EvaluatedTargetPropertyEntry const& entry = entries.Entries.back(); for (auto const& file : entry.Values) { auto* sf = headTarget->Makefile->GetOrCreateSource(file); @@ -142,20 +140,20 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget, } void AddFileSetEntries(cmGeneratorTarget const* headTarget, - std::string const& config, + cm::GenEx::Context const& context, cmGeneratorExpressionDAGChecker* dagChecker, EvaluatedTargetPropertyEntries& entries) { for (auto const& entry : headTarget->Target->GetHeaderSetsEntries()) { for (auto const& name : cmList{ entry.Value }) { auto const* headerSet = headTarget->Target->GetFileSet(name); - addFileSetEntry(headTarget, config, dagChecker, headerSet, entries); + addFileSetEntry(headTarget, context, dagChecker, headerSet, entries); } } for (auto const& entry : headTarget->Target->GetCxxModuleSetsEntries()) { for (auto const& name : cmList{ entry.Value }) { auto const* cxxModuleSet = headTarget->Target->GetFileSet(name); - addFileSetEntry(headTarget, config, dagChecker, cxxModuleSet, entries); + addFileSetEntry(headTarget, context, dagChecker, cxxModuleSet, entries); } } } @@ -251,7 +249,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( }; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, context.Config, context.Language, &dagChecker, this->SourceEntries); + this, context, &dagChecker, this->SourceEntries); std::unordered_set uniqueSrcs; bool contextDependentDirectSources = @@ -259,9 +257,9 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( // Collect INTERFACE_SOURCES of all direct link-dependencies. EvaluatedTargetPropertyEntries linkInterfaceSourcesEntries; - AddInterfaceEntries( - this, context.Config, "INTERFACE_SOURCES", context.Language, &dagChecker, - linkInterfaceSourcesEntries, IncludeRuntimeInterface::No, UseTo::Compile); + AddInterfaceEntries(this, "INTERFACE_SOURCES", context, &dagChecker, + linkInterfaceSourcesEntries, IncludeRuntimeInterface::No, + UseTo::Compile); bool contextDependentInterfaceSources = processSources( this, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources); @@ -269,7 +267,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( bool contextDependentObjects = false; if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) { EvaluatedTargetPropertyEntries linkObjectsEntries; - AddObjectEntries(this, context.Config, &dagChecker, linkObjectsEntries); + AddObjectEntries(this, context, &dagChecker, linkObjectsEntries); contextDependentObjects = processSources(this, linkObjectsEntries, files, uniqueSrcs, debugSources); // Note that for imported targets or multi-config generators supporting @@ -280,7 +278,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( // Collect this target's file sets. EvaluatedTargetPropertyEntries fileSetEntries; - AddFileSetEntries(this, context.Config, &dagChecker, fileSetEntries); + AddFileSetEntries(this, context, &dagChecker, fileSetEntries); bool contextDependentFileSets = processSources(this, fileSetEntries, files, uniqueSrcs, debugSources); diff --git a/Source/cmGeneratorTarget_TargetPropertyEntry.cxx b/Source/cmGeneratorTarget_TargetPropertyEntry.cxx index 90a3ca88b2..d90fa3739c 100644 --- a/Source/cmGeneratorTarget_TargetPropertyEntry.cxx +++ b/Source/cmGeneratorTarget_TargetPropertyEntry.cxx @@ -17,7 +17,12 @@ #include "cmList.h" #include "cmListFileCache.h" -class cmLocalGenerator; +namespace cm { +namespace GenEx { +struct Context; +} +} + class cmake; struct cmGeneratorExpressionDAGChecker; @@ -33,10 +38,9 @@ public: { } - std::string const& Evaluate(cmLocalGenerator*, std::string const&, + std::string const& Evaluate(cm::GenEx::Context const&, cmGeneratorTarget const*, - cmGeneratorExpressionDAGChecker*, - std::string const&) const override + cmGeneratorExpressionDAGChecker*) const override { return this->PropertyValue.Value; } @@ -64,13 +68,11 @@ public: { } - std::string const& Evaluate(cmLocalGenerator* lg, std::string const& config, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language) const override + std::string const& Evaluate( + cm::GenEx::Context const& context, cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker) const override { - return this->ge->Evaluate(lg, config, headTarget, dagChecker, nullptr, - language); + return this->ge->Evaluate(context, dagChecker, headTarget); } cmListFileBacktrace GetBacktrace() const override @@ -105,14 +107,13 @@ public: { } - std::string const& Evaluate(cmLocalGenerator* lg, std::string const& config, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& /*lang*/) const override + std::string const& Evaluate( + cm::GenEx::Context const& context, cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker) const override { std::map> filesPerDir; this->FileSet->EvaluateFileEntry(this->BaseDirs, filesPerDir, - this->EntryCge, lg, config, headTarget, + this->EntryCge, context, headTarget, dagChecker); std::vector files; diff --git a/Source/cmInstallFileSetGenerator.cxx b/Source/cmInstallFileSetGenerator.cxx index 1331661872..7763f4397c 100644 --- a/Source/cmInstallFileSetGenerator.cxx +++ b/Source/cmInstallFileSetGenerator.cxx @@ -126,13 +126,13 @@ cmInstallFileSetGenerator::CalculateFilesPerDir( cm::GenEx::Context context(this->LocalGenerator, config); auto dirCges = this->FileSet->CompileDirectoryEntries(); - auto dirs = this->FileSet->EvaluateDirectoryEntries( - dirCges, context.LG, context.Config, this->Target); + auto dirs = + this->FileSet->EvaluateDirectoryEntries(dirCges, context, this->Target); auto fileCges = this->FileSet->CompileFileEntries(); for (auto const& fileCge : fileCges) { - this->FileSet->EvaluateFileEntry(dirs, result, fileCge, context.LG, - context.Config, this->Target); + this->FileSet->EvaluateFileEntry(dirs, result, fileCge, context, + this->Target); } return result; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 73fed489d5..ccd353e0c8 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -364,12 +364,12 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() auto fileEntries = file_set->CompileFileEntries(); auto directoryEntries = file_set->CompileDirectoryEntries(); auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, context.LG, context.Config, this->GeneratorTarget); + directoryEntries, context, this->GeneratorTarget); std::map> files; for (auto const& entry : fileEntries) { - file_set->EvaluateFileEntry(directories, files, entry, context.LG, - context.Config, this->GeneratorTarget); + file_set->EvaluateFileEntry(directories, files, entry, context, + this->GeneratorTarget); } for (auto const& it : files) { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 7343edcc54..a2ff547f7e 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1971,10 +1971,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() cmGeneratorExpressionDAGChecker dagChecker{ this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, context, }; - AddInterfaceEntries( - this->GenTarget, context.Config, "INTERFACE_AUTOMOC_MACRO_NAMES", - context.Language, &dagChecker, InterfaceAutoMocMacroNamesEntries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", + context, &dagChecker, + InterfaceAutoMocMacroNamesEntries, + IncludeRuntimeInterface::Yes); } } } else { @@ -1982,10 +1982,9 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() cmGeneratorExpressionDAGChecker dagChecker{ this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr, context, }; - AddInterfaceEntries(this->GenTarget, context.Config, - "INTERFACE_AUTOMOC_MACRO_NAMES", context.Language, - &dagChecker, InterfaceAutoMocMacroNamesEntries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries( + this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", context, &dagChecker, + InterfaceAutoMocMacroNamesEntries, IncludeRuntimeInterface::Yes); } for (auto const& entry : InterfaceAutoMocMacroNamesEntries.Entries) {