Преглед изворни кода

ENH: Changing shared library versioned file names on OSX to conform to that platform's convention.

Brad King пре 19 година
родитељ
комит
932e3524fc
3 измењених фајлова са 46 додато и 10 уклоњено
  1. 24 9
      Source/cmFileCommand.cxx
  2. 1 0
      Source/cmFileCommand.h
  3. 21 1
      Source/cmTarget.cxx

+ 24 - 9
Source/cmFileCommand.cxx

@@ -775,15 +775,10 @@ bool cmFileCommand::HandleInstallCommand(
           std::string libname = toFile;
           std::string soname = toFile;
           std::string soname_nopath = fromName;
-          soname += ".";
-          soname += lib_soversion;
-          soname_nopath += ".";
-          soname_nopath += lib_soversion;
-
-          fromName += ".";
-          fromName += lib_version;
-          toFile += ".";
-          toFile += lib_version;
+          this->ComputeVersionedName(soname, lib_soversion);
+          this->ComputeVersionedName(soname_nopath, lib_soversion);
+          this->ComputeVersionedName(fromName, lib_version);
+          this->ComputeVersionedName(toFile, lib_version);
 
           cmSystemTools::RemoveFile(soname.c_str());
           cmSystemTools::RemoveFile(libname.c_str());
@@ -945,6 +940,26 @@ bool cmFileCommand::HandleInstallCommand(
   return true;
 }
 
+//----------------------------------------------------------------------------
+void cmFileCommand::ComputeVersionedName(std::string& name,
+                                         const char* version)
+{
+#if defined(__APPLE__)
+  std::string ext;
+  kwsys_stl::string::size_type dot_pos = name.rfind(".");
+  if(dot_pos != name.npos)
+    {
+    ext = name.substr(dot_pos, name.npos);
+    name = name.substr(0, dot_pos);
+    }
+#endif
+  name += ".";
+  name += version;
+#if defined(__APPLE__)
+  name += ext;
+#endif
+}
+
 //----------------------------------------------------------------------------
 bool cmFileCommand::HandleRelativePathCommand(
   std::vector<std::string> const& args)

+ 1 - 0
Source/cmFileCommand.h

@@ -125,6 +125,7 @@ protected:
   bool HandleRelativePathCommand(std::vector<std::string> const& args);
   bool HandleCMakePathCommand(std::vector<std::string> const& args,
                               bool nativePath);
+  void ComputeVersionedName(std::string& name, const char* version);
 };
 
 

+ 21 - 1
Source/cmTarget.cxx

@@ -1321,19 +1321,36 @@ void cmTarget::GetLibraryNamesInternal(std::string& name,
     soversion = version;
     }
 
+  // Get the components of the library name.
+  std::string prefix;
+  std::string base;
+  std::string suffix;
+  this->GetFullNameInternal(type, config, false, prefix, base, suffix);
+
   // The library name.
-  name = this->GetFullNameInternal(type, config, false);
+  name = prefix+base+suffix;
 
   // The library's soname.
+#if defined(__APPLE__)
+  soName = prefix+base;
+#else
   soName = name;
+#endif
   if(soversion)
     {
     soName += ".";
     soName += soversion;
     }
+#if defined(__APPLE__)
+  soName += suffix;
+#endif
 
   // The library's real name on disk.
+#if defined(__APPLE__)
+  realName = prefix+base;
+#else
   realName = name;
+#endif
   if(version)
     {
     realName += ".";
@@ -1344,6 +1361,9 @@ void cmTarget::GetLibraryNamesInternal(std::string& name,
     realName += ".";
     realName += soversion;
     }
+#if defined(__APPLE__)
+  realName += suffix;
+#endif
 
   // The import library name.
   if(type == cmTarget::SHARED_LIBRARY)