From 09d7f947d68796e8fde923a47636f1c764b5a7af Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 11 Nov 2022 11:44:47 -0500 Subject: cmGeneratorExpression: Require cmake instance --- Source/cmGeneratorTarget.cxx | 59 +++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) (limited to 'Source/cmGeneratorTarget.cxx') diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index becf2447f7..6065285729 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -241,15 +241,16 @@ private: std::unique_ptr< cmGeneratorTarget:: - TargetPropertyEntry> static CreateTargetPropertyEntry(const BT& + TargetPropertyEntry> static CreateTargetPropertyEntry(cmake& cmakeInstance, + const BT< + std::string>& propertyValue, bool evaluateForBuildsystem = false) { if (cmGeneratorExpression::Find(propertyValue.Value) != std::string::npos) { - cmGeneratorExpression ge(propertyValue.Backtrace); + cmGeneratorExpression ge(cmakeInstance, propertyValue.Backtrace); std::unique_ptr cge = ge.Parse(propertyValue.Value); cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); @@ -262,12 +263,13 @@ std::unique_ptr< } static void CreatePropertyGeneratorExpressions( - cmBTStringRange entries, + cmake& cmakeInstance, cmBTStringRange entries, std::vector>& items, bool evaluateForBuildsystem = false) { for (auto const& entry : entries) { - items.push_back(CreateTargetPropertyEntry(entry, evaluateForBuildsystem)); + items.push_back( + CreateTargetPropertyEntry(cmakeInstance, entry, evaluateForBuildsystem)); } } @@ -343,29 +345,36 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator->ComputeTargetObjectDirectory(this); - CreatePropertyGeneratorExpressions(t->GetIncludeDirectoriesEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetIncludeDirectoriesEntries(), this->IncludeDirectoriesEntries); - CreatePropertyGeneratorExpressions(t->GetCompileOptionsEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetCompileOptionsEntries(), this->CompileOptionsEntries); - CreatePropertyGeneratorExpressions(t->GetCompileFeaturesEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetCompileFeaturesEntries(), this->CompileFeaturesEntries); - CreatePropertyGeneratorExpressions(t->GetCompileDefinitionsEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetCompileDefinitionsEntries(), this->CompileDefinitionsEntries); - CreatePropertyGeneratorExpressions(t->GetLinkOptionsEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetLinkOptionsEntries(), this->LinkOptionsEntries); - CreatePropertyGeneratorExpressions(t->GetLinkDirectoriesEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetLinkDirectoriesEntries(), this->LinkDirectoriesEntries); - CreatePropertyGeneratorExpressions(t->GetPrecompileHeadersEntries(), + CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(), + t->GetPrecompileHeadersEntries(), this->PrecompileHeadersEntries); - CreatePropertyGeneratorExpressions(t->GetSourceEntries(), - this->SourceEntries, true); + CreatePropertyGeneratorExpressions( + *lg->GetCMakeInstance(), t->GetSourceEntries(), this->SourceEntries, true); this->PolicyMap = t->GetPolicyMap(); @@ -753,6 +762,7 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src, bool before) this->SourceEntries.insert( before ? this->SourceEntries.begin() : this->SourceEntries.end(), CreateTargetPropertyEntry( + *this->LocalGenerator->GetCMakeInstance(), BT(src, this->Makefile->GetBacktrace()), true)); this->ClearSourcesCache(); } @@ -780,6 +790,7 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src, before ? this->IncludeDirectoriesEntries.begin() : this->IncludeDirectoriesEntries.end(), CreateTargetPropertyEntry( + *this->Makefile->GetCMakeInstance(), BT(src, this->Makefile->GetBacktrace()), true)); } @@ -1653,7 +1664,8 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely( lib.Target); std::string genex = "$"; - cmGeneratorExpression ge(lib.Backtrace); + cmGeneratorExpression ge(*headTarget->Makefile->GetCMakeInstance(), + lib.Backtrace); std::unique_ptr cge = ge.Parse(genex); cge->SetEvaluateForBuildsystem(true); @@ -4192,7 +4204,8 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( } case cmPolicies::OLD: { std::unique_ptr entry = - CreateTargetPropertyEntry(*configProp); + CreateTargetPropertyEntry( + *this->LocalGenerator->GetCMakeInstance(), *configProp); entries.Entries.emplace_back(EvaluateTargetPropertyEntry( this, config, language, &dagChecker, *entry)); } break; @@ -4778,8 +4791,8 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) { std::vector options = cmExpandedList(*linkOptions); for (const auto& option : options) { - std::unique_ptr entry = - CreateTargetPropertyEntry(option); + std::unique_ptr entry = CreateTargetPropertyEntry( + *this->LocalGenerator->GetCMakeInstance(), option); entries.Entries.emplace_back(EvaluateTargetPropertyEntry( this, config, language, &dagChecker, *entry)); } @@ -4931,8 +4944,8 @@ std::vector> cmGeneratorTarget::GetLinkDepends( if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) { std::vector depends = cmExpandedList(*linkDepends); for (const auto& depend : depends) { - std::unique_ptr entry = - CreateTargetPropertyEntry(depend); + std::unique_ptr entry = CreateTargetPropertyEntry( + *this->LocalGenerator->GetCMakeInstance(), depend); entries.Entries.emplace_back(EvaluateTargetPropertyEntry( this, config, language, &dagChecker, *entry)); } @@ -6756,7 +6769,8 @@ void cmGeneratorTarget::ExpandLinkItems( cmMakefile const* mf = this->LocalGenerator->GetMakefile(); LookupLinkItemScope scope{ this->LocalGenerator }; for (BT const& entry : entries) { - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance(), + entry.Backtrace); std::unique_ptr cge = ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); std::vector libs = cmExpandedList( @@ -8195,7 +8209,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( break; } } - cmGeneratorExpression ge(entry.Backtrace); + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance(), + entry.Backtrace); std::unique_ptr const cge = ge.Parse(entry.Value); cge->SetEvaluateForBuildsystem(true); -- cgit v1.2.1