Bladeren bron

ENH: Avoid computing link information for static library targets. They do not link.

Brad King 17 jaren geleden
bovenliggende
commit
410d7b0f36
3 gewijzigde bestanden met toevoegingen van 33 en 21 verwijderingen
  1. 25 20
      Source/cmGlobalXCodeGenerator.cxx
  2. 5 1
      Source/cmMakefileLibraryTargetGenerator.cxx
  3. 3 0
      Source/cmTarget.cxx

+ 25 - 20
Source/cmGlobalXCodeGenerator.cxx

@@ -2092,6 +2092,12 @@ void cmGlobalXCodeGenerator
       } 
       } 
     }
     }
 
 
+  // Skip link information for static libraries.
+  if(cmtarget->GetType() == cmTarget::STATIC_LIBRARY)
+    {
+    return;
+    }
+
   // Loop over configuration types and set per-configuration info.
   // Loop over configuration types and set per-configuration info.
   for(std::vector<std::string>::iterator i =
   for(std::vector<std::string>::iterator i =
         this->CurrentConfigurationTypes.begin();
         this->CurrentConfigurationTypes.begin();
@@ -2166,29 +2172,28 @@ void cmGlobalXCodeGenerator
     }
     }
 
 
     // now add the link libraries
     // now add the link libraries
-    if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY)
-      {
-      std::string linkLibs;
-      const char* sep = "";
-      typedef cmComputeLinkInformation::ItemVector ItemVector;
-      ItemVector const& libNames = cli.GetItems();
-      for(ItemVector::const_iterator li = libNames.begin();
-          li != libNames.end(); ++li)
+    {
+    std::string linkLibs;
+    const char* sep = "";
+    typedef cmComputeLinkInformation::ItemVector ItemVector;
+    ItemVector const& libNames = cli.GetItems();
+    for(ItemVector::const_iterator li = libNames.begin();
+        li != libNames.end(); ++li)
+      {
+      linkLibs += sep;
+      sep = " ";
+      if(li->IsPath)
         {
         {
-        linkLibs += sep;
-        sep = " ";
-        if(li->IsPath)
-          {
-          linkLibs += this->XCodeEscapePath(li->Value.c_str());
-          }
-        else
-          {
-          linkLibs += li->Value;
-          }
+        linkLibs += this->XCodeEscapePath(li->Value.c_str());
+        }
+      else
+        {
+        linkLibs += li->Value;
         }
         }
-      this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
-                                        linkLibs.c_str(), configName);
       }
       }
+    this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
+                                      linkLibs.c_str(), configName);
+    }
     }
     }
 }
 }
 
 

+ 5 - 1
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -720,7 +720,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 
 
   // Collect up flags to link in needed libraries.
   // Collect up flags to link in needed libraries.
   cmOStringStream linklibs;
   cmOStringStream linklibs;
-  this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
+  if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
+    {
+    this->LocalGenerator
+      ->OutputLinkLibraries(linklibs, *this->Target, relink);
+    }
 
 
   // Construct object file lists that may be needed to expand the
   // Construct object file lists that may be needed to expand the
   // rule.
   // rule.

+ 3 - 0
Source/cmTarget.cxx

@@ -3299,6 +3299,9 @@ cmTargetLinkInterface* cmTarget::ComputeLinkInterface(const char* config)
 cmComputeLinkInformation*
 cmComputeLinkInformation*
 cmTarget::GetLinkInformation(const char* config)
 cmTarget::GetLinkInformation(const char* config)
 {
 {
+  // Link information does not make sense for static libraries.
+  assert(this->GetType() != cmTarget::STATIC_LIBRARY);
+
   // Lookup any existing information for this configuration.
   // Lookup any existing information for this configuration.
   std::map<cmStdString, cmComputeLinkInformation*>::iterator
   std::map<cmStdString, cmComputeLinkInformation*>::iterator
     i = this->LinkInformation.find(config?config:"");
     i = this->LinkInformation.find(config?config:"");