diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 98c1c30898..e8057de4f5 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" @@ -522,13 +523,13 @@ std::string cmCommonTargetGenerator::GetLinkerLauncher( std::string propName = lang + "_LINKER_LAUNCHER"; cmValue launcherProp = this->GeneratorTarget->GetProperty(propName); if (cmNonempty(launcherProp)) { - cmGeneratorExpressionDAGChecker dagChecker{ - this->GeneratorTarget, propName, nullptr, nullptr, - this->LocalCommonGenerator, config, - }; + cm::GenEx::Context context(this->LocalCommonGenerator, config, lang); + cmGeneratorExpressionDAGChecker dagChecker{ this->GeneratorTarget, + propName, nullptr, nullptr, + context }; 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 1d3f93340a..3051321561 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,45 +600,42 @@ 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()) { auto item = key.substr(lloPrefix.length()); cmGeneratorExpressionDAGChecker dagChecker{ - this->Target, - "LINK_LIBRARY_OVERRIDE", - nullptr, - nullptr, - this->Target->GetLocalGenerator(), - config, - this->Target->GetBacktrace(), + this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, + context, 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 +645,12 @@ cmComputeLinkDepends::cmComputeLinkDepends(cmGeneratorTarget const* target, if (cmValue linkLibraryOverride = this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) { cmGeneratorExpressionDAGChecker dagChecker{ - target, - "LINK_LIBRARY_OVERRIDE", - nullptr, - nullptr, - target->GetLocalGenerator(), - config, - target->GetBacktrace(), + this->Target, "LINK_LIBRARY_OVERRIDE", nullptr, nullptr, + context, 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 0724561d70..f2162cfabc 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..7f8a9b86ea 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(); @@ -108,12 +110,12 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt, auto fileEntries = file_set->CompileFileEntries(); auto directoryEntries = file_set->CompileDirectoryEntries(); - auto directories = file_set->EvaluateDirectoryEntries( - directoryEntries, gt->LocalGenerator, 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, - gt->LocalGenerator, 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 1e58d79889..d317ffd2d2 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) { - auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, gte->LocalGenerator, config, gte); + cm::GenEx::Context context(gte->LocalGenerator, config); + auto directories = + fileSet->EvaluateDirectoryEntries(directoryEntries, context, gte); bool const contextSensitive = std::any_of(directoryEntries.begin(), directoryEntries.end(), @@ -226,13 +228,13 @@ std::string cmExportBuildCMakeConfigGenerator::GetFileSetFiles( auto directoryEntries = fileSet->CompileDirectoryEntries(); for (auto const& config : configs) { - auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, gte->LocalGenerator, config, gte); + cm::GenEx::Context context(gte->LocalGenerator, config); + auto directories = + fileSet->EvaluateDirectoryEntries(directoryEntries, context, gte); std::map> files; for (auto const& entry : fileEntries) { - fileSet->EvaluateFileEntry(directories, files, entry, - gte->LocalGenerator, config, gte); + fileSet->EvaluateFileEntry(directories, files, entry, context, gte); } bool const contextSensitive = diff --git a/Source/cmExportInstallCMakeConfigGenerator.cxx b/Source/cmExportInstallCMakeConfigGenerator.cxx index 166833d3c4..a039be48dc 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,13 @@ std::string cmExportInstallCMakeConfigGenerator::GetFileSetFiles( te->FileSetGenerators.at(fileSet->GetName())->GetDestination()); for (auto const& config : configs) { - auto directories = fileSet->EvaluateDirectoryEntries( - directoryEntries, gte->LocalGenerator, config, gte); + cm::GenEx::Context context(gte->LocalGenerator, config); + auto directories = + fileSet->EvaluateDirectoryEntries(directoryEntries, context, gte); std::map> files; for (auto const& entry : fileEntries) { - fileSet->EvaluateFileEntry(directories, files, entry, - gte->LocalGenerator, 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 e67df5f7b7..20c0714a43 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); } cmGeneratorExpressionDAGChecker dagChecker{ - tgt, - propName, - nullptr, - parentDagChecker.get(), - tgt->GetLocalGenerator(), - this->Config, + tgt, propName, nullptr, parentDagChecker.get(), context, }; std::unique_ptr cge = ge.Parse(*prop); @@ -103,8 +100,7 @@ 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, &dagChecker, &gDummyHead, tgt); std::set const& allTargets = cge->GetAllTargetsSeen(); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index c1650d8e6a..9e74ca062d 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" @@ -1100,16 +1101,15 @@ 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, 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, target); } Json::Value files = Json::arrayValue; @@ -1633,18 +1633,19 @@ 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); + 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, - this->GT->LocalGenerator, this->Config, + fs->EvaluateFileEntry(directories, files_per_dirs, entry, context, this->GT); } 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 dc99f9b3e1..d34ebf0f35 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); @@ -453,17 +460,18 @@ 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, }; - return this->CompiledGeneratorExpression->Evaluate( - this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr, - this->Language); + return this->CompiledGeneratorExpression->Evaluate(context, &dagChecker, + this->HeadTarget); } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index bda35f48ac..3897e67b61 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/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/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 9dd6177cde..7909fc0c42 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); + this->Condition->Evaluate(context, nullptr, target); if (condResult == "0") { return; } @@ -58,10 +60,9 @@ void cmGeneratorExpressionEvaluationFile::Generate( } } - std::string const outputFileName = - this->GetOutputFileName(lg, target, config, lang); + std::string const outputFileName = this->GetOutputFileName(context, target); std::string const& outputContent = - inputExpression->Evaluate(lg, config, target, nullptr, nullptr, lang); + inputExpression->Evaluate(context, nullptr, target); auto it = outputFiles.find(outputFileName); @@ -123,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 @@ -204,16 +206,16 @@ 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) { std::string outputFileName = - this->OutputFileExpr->Evaluate(lg, config, target, nullptr, nullptr, lang); + this->OutputFileExpr->Evaluate(context, nullptr, target); 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/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 424e4aa02a..91b7907aa3 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; } @@ -481,8 +480,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: @@ -3136,9 +3134,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 4fa320991c..00c5fc82af 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" @@ -632,7 +633,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, @@ -739,12 +740,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, }; - 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; @@ -1208,24 +1210,25 @@ 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, }; 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 = @@ -1235,9 +1238,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); } } } @@ -1998,11 +2001,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, }; - cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator, - config, this, &dagChecker), + cmExpandList(cmGeneratorExpression::Evaluate( + prop, context.LG, context.Config, this, &dagChecker), result); } @@ -5665,17 +5669,17 @@ 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, 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, + this); if (fileCge->GetHadContextSensitiveCondition()) { fileCgesContextSensitive = true; } @@ -6208,15 +6212,16 @@ 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); + auto directories = + file_set->EvaluateDirectoryEntries(directoryEntries, context, 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, this); } for (auto const& it : files) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5f23e4bf0f..ee266ee2f8 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -29,6 +29,7 @@ namespace cm { namespace GenEx { +struct Context; struct Evaluation; } } @@ -1566,10 +1567,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 f3161fe74e..fb6b0c1396 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,16 +45,12 @@ 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, - target->GetBacktrace(), + target, propertyName, nullptr, + dagCheckerParent, context, target->GetBacktrace(), }; switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: @@ -103,14 +100,9 @@ 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, target->GetBacktrace(), }; for (cmLinkImplItem const& library : libraries->Libraries) { @@ -137,8 +129,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 +223,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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -244,7 +237,7 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( this->DebugIncludesDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, lang, &dagChecker, this->IncludeDirectoriesEntries); + this, context, &dagChecker, this->IncludeDirectoriesEntries); if (lang == "Swift") { AddLangSpecificImplicitIncludeDirectories( @@ -271,7 +264,7 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( entries); } - AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES", lang, + AddInterfaceEntries(this, "INTERFACE_INCLUDE_DIRECTORIES", context, &dagChecker, entries, IncludeRuntimeInterface::Yes); processIncludeDirectories(this, entries, includes, uniqueIncludes, diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index 39517553a8..4e43e6db9b 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,14 @@ 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, cmListFileBacktrace(), cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes, }; @@ -565,9 +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(this->LocalGenerator, config, headTarget, - &dagChecker, this, - headTarget->LinkerLanguage) }; + cmList libs{ cge->Evaluate(context, &dagChecker, headTarget, this) }; auto linkFeature = cmLinkItem::DEFAULT; for (auto const& lib : libs) { @@ -1133,6 +1133,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 +1147,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( "LINK_LIBRARIES", nullptr, nullptr, - this->LocalGenerator, - config, + context, cmListFileBacktrace(), cmGeneratorExpressionDAGChecker::ComputingLinkLibraries::Yes, }; @@ -1168,9 +1169,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( std::unique_ptr const cge = ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); - std::string const& evaluated = - cge->Evaluate(this->LocalGenerator, config, this, &dagChecker, nullptr, - this->LinkerLanguage); + 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 4846d6ffa1..7b34b8f649 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,9 @@ 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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -134,10 +136,10 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( this->DebugLinkDirectoriesDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->LinkDirectoriesEntries); + this, context, &dagChecker, this->LinkDirectoriesEntries); - AddInterfaceEntries(this, config, "INTERFACE_LINK_DIRECTORIES", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, + AddInterfaceEntries(this, "INTERFACE_LINK_DIRECTORIES", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes, this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link : UseTo::Compile); diff --git a/Source/cmGeneratorTarget_Options.cxx b/Source/cmGeneratorTarget_Options.cxx index 63baa1d544..012e6457c7 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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -242,10 +245,10 @@ std::vector> cmGeneratorTarget::GetCompileOptions( this->DebugCompileOptionsDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->CompileOptionsEntries); + this, context, &dagChecker, this->CompileOptionsEntries); - AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS", 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); @@ -270,8 +273,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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -282,11 +288,10 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( this->DebugCompileFeaturesDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, std::string(), &dagChecker, this->CompileFeaturesEntries); + this, context, &dagChecker, this->CompileFeaturesEntries); - AddInterfaceEntries(this, config, "INTERFACE_COMPILE_FEATURES", - std::string(), &dagChecker, entries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries(this, "INTERFACE_COMPILE_FEATURES", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes); processOptions(this, entries, result, uniqueFeatures, debugFeatures, "compile features", OptionsParse::None); @@ -319,9 +324,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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -332,9 +338,9 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( this->DebugCompileDefinitionsDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->CompileDefinitionsEntries); + this, context, &dagChecker, this->CompileDefinitionsEntries); - AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS", language, + AddInterfaceEntries(this, "INTERFACE_COMPILE_DEFINITIONS", context, &dagChecker, entries, IncludeRuntimeInterface::Yes); processOptions(this, entries, list, uniqueOptions, debugDefines, @@ -356,8 +362,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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -369,9 +377,9 @@ std::vector> cmGeneratorTarget::GetPrecompileHeaders( this->DebugPrecompileHeadersDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->PrecompileHeadersEntries); + this, context, &dagChecker, this->PrecompileHeadersEntries); - AddInterfaceEntries(this, config, "INTERFACE_PRECOMPILE_HEADERS", language, + AddInterfaceEntries(this, "INTERFACE_PRECOMPILE_HEADERS", context, &dagChecker, entries, IncludeRuntimeInterface::Yes); std::vector> list; @@ -413,8 +421,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, }; cmList debugProperties{ this->Makefile->GetDefinition( @@ -425,10 +435,10 @@ std::vector> cmGeneratorTarget::GetLinkOptions( this->DebugLinkOptionsDone = true; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, language, &dagChecker, this->LinkOptionsEntries); + this, context, &dagChecker, this->LinkOptionsEntries); - AddInterfaceEntries(this, config, "INTERFACE_LINK_OPTIONS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, + AddInterfaceEntries(this, "INTERFACE_LINK_OPTIONS", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes, this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link : UseTo::Compile); @@ -595,17 +605,18 @@ 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, }; EvaluatedTargetPropertyEntries entries; if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) { std::unique_ptr entry = TargetPropertyEntry::Create( *this->LocalGenerator->GetCMakeInstance(), *linkOptions); - entries.Entries.emplace_back(EvaluateTargetPropertyEntry( - this, config, language, &dagChecker, *entry)); + entries.Entries.emplace_back( + EvaluateTargetPropertyEntry(this, context, &dagChecker, *entry)); } processOptions(this, entries, result, uniqueOptions, false, "static library link options", OptionsParse::Shell); @@ -640,8 +651,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, }; EvaluatedTargetPropertyEntries entries; @@ -650,12 +662,12 @@ 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, config, language, &dagChecker, *entry)); + entries.Entries.emplace_back( + EvaluateTargetPropertyEntry(this, context, &dagChecker, *entry)); } } - AddInterfaceEntries(this, config, "INTERFACE_LINK_DEPENDS", language, - &dagChecker, entries, IncludeRuntimeInterface::Yes, + AddInterfaceEntries(this, "INTERFACE_LINK_DEPENDS", context, &dagChecker, + entries, IncludeRuntimeInterface::Yes, this->GetPolicyStatusCMP0099() == cmPolicies::NEW ? UseTo::Link : UseTo::Compile); diff --git a/Source/cmGeneratorTarget_Sources.cxx b/Source/cmGeneratorTarget_Sources.cxx index ed002e450e..b70874dedb 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" @@ -46,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 && @@ -66,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; @@ -79,14 +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) { auto dirCges = fileSet->CompileDirectoryEntries(); - auto dirs = fileSet->EvaluateDirectoryEntries( - dirCges, headTarget->GetLocalGenerator(), config, headTarget, dagChecker); + auto dirs = fileSet->EvaluateDirectoryEntries(dirCges, context, headTarget, + dagChecker); bool contextSensitiveDirs = false; for (auto const& dirCge : dirCges) { if (dirCge->GetHadContextSensitiveCondition()) { @@ -100,7 +101,7 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget, cmGeneratorTarget::TargetPropertyEntry::CreateFileSet( dirs, contextSensitiveDirs, std::move(entryCge), fileSet); entries.Entries.emplace_back(EvaluateTargetPropertyEntry( - headTarget, config, "", dagChecker, *targetPropEntry)); + headTarget, context, dagChecker, *targetPropEntry)); EvaluatedTargetPropertyEntry const& entry = entries.Entries.back(); for (auto const& file : entry.Values) { auto* sf = headTarget->Makefile->GetOrCreateSource(file); @@ -140,20 +141,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); } } } @@ -241,12 +242,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, }; EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( - this, config, std::string(), &dagChecker, this->SourceEntries); + this, context, &dagChecker, this->SourceEntries); std::unordered_set uniqueSrcs; bool contextDependentDirectSources = @@ -254,9 +258,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, "INTERFACE_SOURCES", context, &dagChecker, + linkInterfaceSourcesEntries, IncludeRuntimeInterface::No, + UseTo::Compile); bool contextDependentInterfaceSources = processSources( this, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources); @@ -264,7 +268,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( bool contextDependentObjects = false; if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) { EvaluatedTargetPropertyEntries linkObjectsEntries; - AddObjectEntries(this, 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 @@ -275,7 +279,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( // Collect this target's file sets. EvaluatedTargetPropertyEntries fileSetEntries; - AddFileSetEntries(this, 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/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/cmInstallFileSetGenerator.cxx b/Source/cmInstallFileSetGenerator.cxx index e92f4299d7..7763f4397c 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); + 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, this->LocalGenerator, 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 9d5d80dc8e..733c549393 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,13 +364,11 @@ 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, this->GeneratorTarget); std::map> files; for (auto const& entry : fileEntries) { - file_set->EvaluateFileEntry(directories, files, entry, - this->LocalGenerator, this->GetConfigName(), + file_set->EvaluateFileEntry(directories, files, entry, context, this->GeneratorTarget); } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 741f5fcd79..a2dc232dd7 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" @@ -1977,25 +1978,24 @@ 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, }; - AddInterfaceEntries(this->GenTarget, cfg, - "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", - &dagChecker, InterfaceAutoMocMacroNamesEntries, + AddInterfaceEntries(this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", + context, &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, }; - AddInterfaceEntries(this->GenTarget, this->ConfigDefault, - "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker, - InterfaceAutoMocMacroNamesEntries, - IncludeRuntimeInterface::Yes); + AddInterfaceEntries( + this->GenTarget, "INTERFACE_AUTOMOC_MACRO_NAMES", context, &dagChecker, + InterfaceAutoMocMacroNamesEntries, IncludeRuntimeInterface::Yes); } for (auto const& entry : InterfaceAutoMocMacroNamesEntries.Entries) {