Browse Source

cmGeneratorTarget: Track when the set of link libs is config-dependent

Report in `cmLinkImplementationLibraries` and `cmLinkInterfaceLibraries`
whether the list of libraries depends on a genex referencing the
configuration.  We already track whether a genex references the head
target.
Brad King 5 years ago
parent
commit
fcd1a1a920
3 changed files with 16 additions and 0 deletions
  1. 9 0
      Source/cmGeneratorTarget.cxx
  2. 1 0
      Source/cmGeneratorTarget.h
  3. 6 0
      Source/cmLinkItem.h

+ 9 - 0
Source/cmGeneratorTarget.cxx

@@ -5885,6 +5885,7 @@ void cmGeneratorTarget::ExpandLinkItems(
   std::string const& prop, std::string const& value, std::string const& config,
   cmGeneratorTarget const* headTarget, bool usage_requirements_only,
   std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition,
+  bool& hadContextSensitiveCondition,
   bool& hadLinkLanguageSensitiveCondition) const
 {
   // Keep this logic in sync with ComputeLinkImplementationLibraries.
@@ -5903,6 +5904,7 @@ void cmGeneratorTarget::ExpandLinkItems(
                libs);
   this->LookupLinkItems(libs, cge->GetBacktrace(), items);
   hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
+  hadContextSensitiveCondition = cge->GetHadContextSensitiveCondition();
   hadLinkLanguageSensitiveCondition =
     cge->GetHadLinkLanguageSensitiveCondition();
 }
@@ -6407,6 +6409,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
     this->ExpandLinkItems(linkIfaceProp, *explicitLibraries, config,
                           headTarget, usage_requirements_only, iface.Libraries,
                           iface.HadHeadSensitiveCondition,
+                          iface.HadContextSensitiveCondition,
                           iface.HadLinkLanguageSensitiveCondition);
   } else if (!cmp0022NEW)
   // If CMP0022 is NEW then the plain tll signature sets the
@@ -6427,10 +6430,12 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
       static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
       if (cmProp newExplicitLibraries = this->GetProperty(newProp)) {
         bool hadHeadSensitiveConditionDummy = false;
+        bool hadContextSensitiveConditionDummy = false;
         bool hadLinkLanguageSensitiveConditionDummy = false;
         this->ExpandLinkItems(newProp, *newExplicitLibraries, config,
                               headTarget, usage_requirements_only, ifaceLibs,
                               hadHeadSensitiveConditionDummy,
+                              hadContextSensitiveConditionDummy,
                               hadLinkLanguageSensitiveConditionDummy);
       }
       if (ifaceLibs != iface.Libraries) {
@@ -6498,6 +6503,7 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
     this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config,
                           headTarget, usage_requirements_only, iface.Libraries,
                           iface.HadHeadSensitiveCondition,
+                          iface.HadContextSensitiveCondition,
                           iface.HadLinkLanguageSensitiveCondition);
     std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
     this->LookupLinkItems(deps, cmListFileBacktrace(), iface.SharedDeps);
@@ -7020,6 +7026,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
     if (cge->GetHadHeadSensitiveCondition()) {
       impl.HadHeadSensitiveCondition = true;
     }
+    if (cge->GetHadContextSensitiveCondition()) {
+      impl.HadContextSensitiveCondition = true;
+    }
     if (cge->GetHadLinkLanguageSensitiveCondition()) {
       impl.HadLinkLanguageSensitiveCondition = true;
     }

+ 1 - 0
Source/cmGeneratorTarget.h

@@ -989,6 +989,7 @@ private:
                        bool usage_requirements_only,
                        std::vector<cmLinkItem>& items,
                        bool& hadHeadSensitiveCondition,
+                       bool& hadContextSensitiveCondition,
                        bool& hadLinkLanguageSensitiveCondition) const;
   void LookupLinkItems(std::vector<std::string> const& names,
                        cmListFileBacktrace const& bt,

+ 6 - 0
Source/cmLinkItem.h

@@ -54,6 +54,9 @@ struct cmLinkImplementationLibraries
   // Libraries linked directly in other configurations.
   // Needed only for OLD behavior of CMP0003.
   std::vector<cmLinkItem> WrongConfigLibraries;
+
+  // Whether the list depends on a genex referencing the configuration.
+  bool HadContextSensitiveCondition = false;
 };
 
 struct cmLinkInterfaceLibraries
@@ -63,6 +66,9 @@ struct cmLinkInterfaceLibraries
 
   // Whether the list depends on a genex referencing the head target.
   bool HadHeadSensitiveCondition = false;
+
+  // Whether the list depends on a genex referencing the configuration.
+  bool HadContextSensitiveCondition = false;
 };
 
 struct cmLinkInterface : public cmLinkInterfaceLibraries