瀏覽代碼

cmGeneratorExpressionDAGChecker: Make config name available in constructor

Brad King 1 年之前
父節點
當前提交
633afa0b2e

+ 3 - 3
Source/cmCommonTargetGenerator.cxx

@@ -500,9 +500,9 @@ 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);
+    cmGeneratorExpressionDAGChecker dagChecker(
+      this->GeneratorTarget, propName, nullptr, nullptr,
+      this->LocalCommonGenerator, config);
     std::string evaluatedLinklauncher = cmGeneratorExpression::Evaluate(
       *launcherProp, this->LocalCommonGenerator, config, this->GeneratorTarget,
       &dagChecker, this->GeneratorTarget, lang);

+ 4 - 2
Source/cmComputeLinkDepends.cxx

@@ -581,7 +581,8 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
               "LINK_LIBRARY_OVERRIDE",
               nullptr,
               nullptr,
-              this->Target->GetLocalGenerator()
+              this->Target->GetLocalGenerator(),
+              config
             };
             auto overrideFeature = cmGeneratorExpression::Evaluate(
               *feature, this->Target->GetLocalGenerator(), config,
@@ -599,7 +600,8 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
                                          "LINK_LIBRARY_OVERRIDE",
                                          nullptr,
                                          nullptr,
-                                         target->GetLocalGenerator() };
+                                         target->GetLocalGenerator(),
+                                         config };
     auto overrideValue = cmGeneratorExpression::Evaluate(
       *linkLibraryOverride, target->GetLocalGenerator(), config, target, &dag,
       target, linkLanguage);

+ 4 - 2
Source/cmExportTryCompileFileGenerator.cxx

@@ -76,10 +76,12 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
     // To please constraint checks of DAGChecker, this property must have
     // LINK_OPTIONS property as parent
     parentDagChecker = cm::make_unique<cmGeneratorExpressionDAGChecker>(
-      tgt, "LINK_OPTIONS", nullptr, nullptr, tgt->GetLocalGenerator());
+      tgt, "LINK_OPTIONS", nullptr, nullptr, tgt->GetLocalGenerator(),
+      this->Config);
   }
   cmGeneratorExpressionDAGChecker dagChecker(
-    tgt, propName, nullptr, parentDagChecker.get(), tgt->GetLocalGenerator());
+    tgt, propName, nullptr, parentDagChecker.get(), tgt->GetLocalGenerator(),
+    this->Config);
 
   std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);
 

+ 1 - 1
Source/cmGeneratorExpression.cxx

@@ -425,7 +425,7 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate(
   cmGeneratorExpressionDAGChecker dagChecker(
     this->HeadTarget,
     property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr,
-    nullptr, this->LocalGenerator);
+    nullptr, this->LocalGenerator, this->Config);
 
   return this->CompiledGeneratorExpression->Evaluate(
     this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr,

+ 6 - 3
Source/cmGeneratorExpressionDAGChecker.cxx

@@ -20,17 +20,19 @@
 cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
   cmGeneratorTarget const* target, std::string property,
   const GeneratorExpressionContent* content,
-  cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG)
+  cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG,
+  std::string const& contextConfig)
   : cmGeneratorExpressionDAGChecker(cmListFileBacktrace(), target,
                                     std::move(property), content, parent,
-                                    contextLG)
+                                    contextLG, contextConfig)
 {
 }
 
 cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
   cmListFileBacktrace backtrace, cmGeneratorTarget const* target,
   std::string property, const GeneratorExpressionContent* content,
-  cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG)
+  cmGeneratorExpressionDAGChecker* parent, cmLocalGenerator const* contextLG,
+  std::string const& contextConfig)
   : Parent(parent)
   , Top(parent ? parent->Top : this)
   , Target(target)
@@ -38,6 +40,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
   , Content(content)
   , Backtrace(std::move(backtrace))
 {
+  static_cast<void>(contextConfig);
   if (parent) {
     this->TopIsTransitiveProperty = parent->TopIsTransitiveProperty;
   } else {

+ 4 - 2
Source/cmGeneratorExpressionDAGChecker.h

@@ -22,12 +22,14 @@ struct cmGeneratorExpressionDAGChecker
                                   std::string property,
                                   const GeneratorExpressionContent* content,
                                   cmGeneratorExpressionDAGChecker* parent,
-                                  cmLocalGenerator const* contextLG);
+                                  cmLocalGenerator const* contextLG,
+                                  std::string const& contextConfig);
   cmGeneratorExpressionDAGChecker(cmGeneratorTarget const* target,
                                   std::string property,
                                   const GeneratorExpressionContent* content,
                                   cmGeneratorExpressionDAGChecker* parent,
-                                  cmLocalGenerator const* contextLG);
+                                  cmLocalGenerator const* contextLG,
+                                  std::string const& contextConfig);
 
   enum Result
   {

+ 4 - 4
Source/cmGeneratorExpressionNode.cxx

@@ -488,7 +488,7 @@ protected:
       cmGeneratorExpressionDAGChecker dagChecker(
         context->Backtrace, context->HeadTarget,
         genexOperator + ":" + expression, content, dagCheckerParent,
-        context->LG);
+        context->LG, context->Config);
       switch (dagChecker.Check()) {
         case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
         case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: {
@@ -2915,9 +2915,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
                                           dagCheckerParent, usage));
     }
 
-    cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, target,
-                                               propertyName, content,
-                                               dagCheckerParent, context->LG);
+    cmGeneratorExpressionDAGChecker dagChecker(
+      context->Backtrace, target, propertyName, content, dagCheckerParent,
+      context->LG, context->Config);
 
     switch (dagChecker.Check()) {
       case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:

+ 5 - 5
Source/cmGeneratorTarget.cxx

@@ -709,8 +709,8 @@ std::string cmGeneratorTarget::GetLinkerTypeProperty(
   std::string propName{ "LINKER_TYPE" };
   auto linkerType = this->GetProperty(propName);
   if (!linkerType.IsEmpty()) {
-    cmGeneratorExpressionDAGChecker dagChecker(this, propName, nullptr,
-                                               nullptr, this->LocalGenerator);
+    cmGeneratorExpressionDAGChecker dagChecker(
+      this, propName, nullptr, nullptr, this->LocalGenerator, config);
     auto ltype =
       cmGeneratorExpression::Evaluate(*linkerType, this->GetLocalGenerator(),
                                       config, this, &dagChecker, this, lang);
@@ -1176,7 +1176,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(
   if (iter == this->SystemIncludesCache.end()) {
     cmGeneratorExpressionDAGChecker dagChecker(
       this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr,
-      this->LocalGenerator);
+      this->LocalGenerator, config);
 
     bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
 
@@ -1936,8 +1936,8 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
     return;
   }
 
-  cmGeneratorExpressionDAGChecker dagChecker(this, "AUTOUIC_OPTIONS", nullptr,
-                                             nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
   cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator,
                                                config, this, &dagChecker),
                result);

+ 7 - 6
Source/cmGeneratorTarget_IncludeDirectories.cxx

@@ -48,8 +48,8 @@ std::string AddLangSpecificInterfaceIncludeDirectories(
   cmGeneratorExpressionDAGChecker* context)
 {
   cmGeneratorExpressionDAGChecker dag{
-    target->GetBacktrace(),     target, propertyName, nullptr, context,
-    target->GetLocalGenerator()
+    target->GetBacktrace(),      target, propertyName, nullptr, context,
+    target->GetLocalGenerator(), config
   };
   switch (dag.Check()) {
     case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
@@ -101,8 +101,8 @@ void AddLangSpecificImplicitIncludeDirectories(
   if (const auto* libraries =
         target->GetLinkImplementationLibraries(config, UseTo::Compile)) {
     cmGeneratorExpressionDAGChecker dag{
-      target->GetBacktrace(),     target, propertyName, nullptr, nullptr,
-      target->GetLocalGenerator()
+      target->GetBacktrace(),      target, propertyName, nullptr, nullptr,
+      target->GetLocalGenerator(), config
     };
 
     for (const cmLinkImplItem& library : libraries->Libraries) {
@@ -254,8 +254,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
   std::vector<BT<std::string>> includes;
   std::unordered_set<std::string> uniqueIncludes;
 
-  cmGeneratorExpressionDAGChecker dagChecker(
-    this, "INCLUDE_DIRECTORIES", nullptr, nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES",
+                                             nullptr, nullptr,
+                                             this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };

+ 3 - 3
Source/cmGeneratorTarget_Link.cxx

@@ -521,7 +521,7 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
   }
   // Keep this logic in sync with ComputeLinkImplementationLibraries.
   cmGeneratorExpressionDAGChecker dagChecker(this, prop, nullptr, nullptr,
-                                             this->LocalGenerator);
+                                             this->LocalGenerator, config);
   // The $<LINK_ONLY> expression may be in a link interface to specify
   // private link dependencies that are otherwise excluded from usage
   // requirements.
@@ -1271,8 +1271,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
   // Collect libraries directly linked in this configuration.
   for (auto const& entry : entryRange) {
     // Keep this logic in sync with ExpandLinkItems.
-    cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_LIBRARIES", nullptr,
-                                               nullptr, this->LocalGenerator);
+    cmGeneratorExpressionDAGChecker dagChecker(
+      this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config);
     // The $<LINK_ONLY> expression may be used to specify link dependencies
     // that are otherwise excluded from usage requirements.
     if (usage == UseTo::Compile) {

+ 2 - 2
Source/cmGeneratorTarget_LinkDirectories.cxx

@@ -125,8 +125,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
   std::vector<BT<std::string>> result;
   std::unordered_set<std::string> uniqueDirectories;
 
-  cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_DIRECTORIES", nullptr,
-                                             nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };

+ 17 - 14
Source/cmGeneratorTarget_Options.cxx

@@ -217,8 +217,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
   std::vector<BT<std::string>> result;
   std::unordered_set<std::string> uniqueOptions;
 
-  cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_OPTIONS", nullptr,
-                                             nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -258,8 +258,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
   std::vector<BT<std::string>> result;
   std::unordered_set<std::string> uniqueFeatures;
 
-  cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_FEATURES", nullptr,
-                                             nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -308,8 +308,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
   std::vector<BT<std::string>> list;
   std::unordered_set<std::string> uniqueOptions;
 
-  cmGeneratorExpressionDAGChecker dagChecker(
-    this, "COMPILE_DEFINITIONS", nullptr, nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS",
+                                             nullptr, nullptr,
+                                             this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -372,8 +373,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
   }
   std::unordered_set<std::string> uniqueOptions;
 
-  cmGeneratorExpressionDAGChecker dagChecker(
-    this, "PRECOMPILE_HEADERS", nullptr, nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS",
+                                             nullptr, nullptr,
+                                             this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -430,8 +432,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
   std::vector<BT<std::string>> result;
   std::unordered_set<std::string> uniqueOptions;
 
-  cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_OPTIONS", nullptr,
-                                             nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
 
   cmList debugProperties{ this->Makefile->GetDefinition(
     "CMAKE_DEBUG_TARGET_PROPERTIES") };
@@ -599,8 +601,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
   std::vector<BT<std::string>> result;
   std::unordered_set<std::string> uniqueOptions;
 
-  cmGeneratorExpressionDAGChecker dagChecker(
-    this, "STATIC_LIBRARY_OPTIONS", nullptr, nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(this, "STATIC_LIBRARY_OPTIONS",
+                                             nullptr, nullptr,
+                                             this->LocalGenerator, config);
 
   EvaluatedTargetPropertyEntries entries;
   if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
@@ -631,8 +634,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
 {
   std::vector<BT<std::string>> result;
   std::unordered_set<std::string> uniqueOptions;
-  cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_DEPENDS", nullptr,
-                                             nullptr, this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config);
 
   EvaluatedTargetPropertyEntries entries;
   if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) {

+ 1 - 1
Source/cmGeneratorTarget_Sources.cxx

@@ -265,7 +265,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
   }
 
   cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr, nullptr,
-                                             this->LocalGenerator);
+                                             this->LocalGenerator, config);
 
   EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
     this, config, std::string(), &dagChecker, this->SourceEntries);

+ 3 - 3
Source/cmGeneratorTarget_TransitiveProperty.cxx

@@ -107,9 +107,9 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
   // Evaluate $<TARGET_PROPERTY:this,prop> as if it were compiled.  This is
   // a subset of TargetPropertyNode::Evaluate without stringify/parse steps
   // but sufficient for transitive interface properties.
-  cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, this, prop,
-                                             nullptr, dagCheckerParent,
-                                             this->LocalGenerator);
+  cmGeneratorExpressionDAGChecker dagChecker(
+    context->Backtrace, this, prop, nullptr, dagCheckerParent,
+    this->LocalGenerator, context->Config);
   switch (dagChecker.Check()) {
     case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
       dagChecker.ReportError(

+ 6 - 3
Source/cmQtAutoGenInitializer.cxx

@@ -1918,14 +1918,14 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
     info.SetBool("MOC_RELAXED_MODE", this->Moc.RelaxedMode);
     info.SetBool("MOC_PATH_PREFIX", this->Moc.PathPrefix);
 
-    cmGeneratorExpressionDAGChecker dagChecker(this->GenTarget,
-                                               "AUTOMOC_MACRO_NAMES", nullptr,
-                                               nullptr, this->LocalGen);
     EvaluatedTargetPropertyEntries InterfaceAutoMocMacroNamesEntries;
 
     if (this->MultiConfig) {
       for (auto const& cfg : this->ConfigsList) {
         if (!cfg.empty()) {
+          cmGeneratorExpressionDAGChecker dagChecker(
+            this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
+            this->LocalGen, cfg);
           AddInterfaceEntries(this->GenTarget, cfg,
                               "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX",
                               &dagChecker, InterfaceAutoMocMacroNamesEntries,
@@ -1933,6 +1933,9 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
         }
       }
     } else {
+      cmGeneratorExpressionDAGChecker dagChecker(
+        this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
+        this->LocalGen, this->ConfigDefault);
       AddInterfaceEntries(this->GenTarget, this->ConfigDefault,
                           "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker,
                           InterfaceAutoMocMacroNamesEntries,