Browse Source

cmGeneratorTarget: Move GetSOName from cmTarget..

Stephen Kelly 10 years ago
parent
commit
41abdc17df

+ 10 - 6
Source/cmComputeLinkInformation.cxx

@@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
     return;
     }
 
+  cmGeneratorTarget *gtgt = 0;
+
   // Get a full path to the dependent shared library.
   // Add it to the runtime path computation so that the target being
   // linked will be able to find it.
   std::string lib;
   if(tgt)
     {
-    cmGeneratorTarget *gtgt = tgt->GetMakefile()
-                                 ->GetGlobalGenerator()
-                                 ->GetGeneratorTarget(tgt);
+    gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt);
+
     lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary);
     this->AddLibraryRuntimeInfo(lib, tgt);
     }
@@ -790,9 +791,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
     }
   if(order)
     {
-    if(tgt)
+    if(gtgt)
       {
-      std::string soName = tgt->GetSOName(this->Config);
+      std::string soName = gtgt->GetSOName(this->Config);
       const char* soname = soName.empty()? 0 : soName.c_str();
       order->AddRuntimeLibrary(lib, soname);
       }
@@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
 
   // Try to get the soname of the library.  Only files with this name
   // could possibly conflict.
-  std::string soName = target->GetSOName(this->Config);
+  cmGeneratorTarget *gtgt = target->GetMakefile()
+                                  ->GetGlobalGenerator()
+                                  ->GetGeneratorTarget(target);
+  std::string soName = gtgt->GetSOName(this->Config);
   const char* soname = soName.empty()? 0 : soName.c_str();
 
   // Include this library in the runtime path ordering.

+ 1 - 1
Source/cmExportFileGenerator.cxx

@@ -895,7 +895,7 @@ cmExportFileGenerator
           value = this->InstallNameDir(target->Target, config);
           }
         prop = "IMPORTED_SONAME";
-        value += target->Target->GetSOName(config);
+        value += target->GetSOName(config);
         }
       else
         {

+ 1 - 1
Source/cmGeneratorExpressionNode.cxx

@@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
       }
     std::string result = target->Target->GetDirectory(context->Config);
     result += "/";
-    result += target->Target->GetSOName(context->Config);
+    result += target->GetSOName(context->Config);
     return result;
   }
 };

+ 43 - 0
Source/cmGeneratorTarget.cxx

@@ -649,6 +649,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
   this->Target->GetSourceFiles(files, config);
 }
 
+//----------------------------------------------------------------------------
+std::string cmGeneratorTarget::GetSOName(const std::string& config) const
+{
+  if(this->Target->IsImported())
+    {
+    // Lookup the imported soname.
+    if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config))
+      {
+      if(info->NoSOName)
+        {
+        // The imported library has no builtin soname so the name
+        // searched at runtime will be just the filename.
+        return cmSystemTools::GetFilenameName(info->Location);
+        }
+      else
+        {
+        // Use the soname given if any.
+        if(info->SOName.find("@rpath/") == 0)
+          {
+          return info->SOName.substr(6);
+          }
+        return info->SOName;
+        }
+      }
+    else
+      {
+      return "";
+      }
+    }
+  else
+    {
+    // Compute the soname that will be built.
+    std::string name;
+    std::string soName;
+    std::string realName;
+    std::string impName;
+    std::string pdbName;
+    this->Target->GetLibraryNames(name, soName, realName,
+                                  impName, pdbName, config);
+    return soName;
+    }
+}
+
 //----------------------------------------------------------------------------
 std::string
 cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const

+ 3 - 0
Source/cmGeneratorTarget.h

@@ -90,6 +90,9 @@ public:
                                 bool realname) const;
   std::string NormalGetRealName(const std::string& config) const;
 
+  /** Get the soname of the target.  Allowed only for a shared library.  */
+  std::string GetSOName(const std::string& config) const;
+
   cmTarget* Target;
   cmMakefile* Makefile;
   cmLocalGenerator* LocalGenerator;

+ 1 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
       install_name += install_name_dir;
       install_name += "/";
       }
-    install_name += target.GetSOName(configName);
+    install_name += gtgt->GetSOName(configName);
 
     if((realName != soName) || install_name_dir.empty())
       {

+ 0 - 57
Source/cmTarget.cxx

@@ -68,21 +68,6 @@ struct cmTarget::OutputInfo
   std::string PdbDir;
 };
 
-//----------------------------------------------------------------------------
-struct cmTarget::ImportInfo
-{
-  ImportInfo(): NoSOName(false), Multiplicity(0) {}
-  bool NoSOName;
-  int Multiplicity;
-  std::string Location;
-  std::string SOName;
-  std::string ImportLibrary;
-  std::string Languages;
-  std::string Libraries;
-  std::string LibrariesProp;
-  std::string SharedDeps;
-};
-
 //----------------------------------------------------------------------------
 struct cmTarget::CompileInfo
 {
@@ -3601,48 +3586,6 @@ bool cmTarget::HasSOName(const std::string& config) const
           this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config)));
 }
 
-//----------------------------------------------------------------------------
-std::string cmTarget::GetSOName(const std::string& config) const
-{
-  if(this->IsImported())
-    {
-    // Lookup the imported soname.
-    if(cmTarget::ImportInfo const* info = this->GetImportInfo(config))
-      {
-      if(info->NoSOName)
-        {
-        // The imported library has no builtin soname so the name
-        // searched at runtime will be just the filename.
-        return cmSystemTools::GetFilenameName(info->Location);
-        }
-      else
-        {
-        // Use the soname given if any.
-        if(info->SOName.find("@rpath/") == 0)
-          {
-          return info->SOName.substr(6);
-          }
-        return info->SOName;
-        }
-      }
-    else
-      {
-      return "";
-      }
-    }
-  else
-    {
-    // Compute the soname that will be built.
-    std::string name;
-    std::string soName;
-    std::string realName;
-    std::string impName;
-    std::string pdbName;
-    this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
-    return soName;
-    }
-}
-
 //----------------------------------------------------------------------------
 bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const
 {

+ 14 - 4
Source/cmTarget.h

@@ -411,9 +411,6 @@ public:
   /** Whether this library has soname enabled and platform supports it.  */
   bool HasSOName(const std::string& config) const;
 
-  /** Get the soname of the target.  Allowed only for a shared library.  */
-  std::string GetSOName(const std::string& config) const;
-
   /** Whether this library has \@rpath and platform supports it.  */
   bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
 
@@ -768,7 +765,20 @@ private:
                            std::string& out) const;
 
   // Cache import information from properties for each configuration.
-  struct ImportInfo;
+  struct ImportInfo
+  {
+    ImportInfo(): NoSOName(false), Multiplicity(0) {}
+    bool NoSOName;
+    int Multiplicity;
+    std::string Location;
+    std::string SOName;
+    std::string ImportLibrary;
+    std::string Languages;
+    std::string Libraries;
+    std::string LibrariesProp;
+    std::string SharedDeps;
+  };
+
   ImportInfo const* GetImportInfo(const std::string& config) const;
   void ComputeImportInfo(std::string const& desired_config,
                          ImportInfo& info) const;