[Cmake-commits] [cmake-commits] king committed cmGlobalXCodeGenerator.cxx 1.194 1.195 cmMakefileLibraryTargetGenerator.cxx 1.61 1.62 cmMakefileLibraryTargetGenerator.h 1.7 1.8

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Jul 9 10:09:49 EDT 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv18003/Source

Modified Files:
	cmGlobalXCodeGenerator.cxx 
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.h 
Log Message:
ENH: Set version info for shared libs on OSX.

  - Map SOVERSION major.minor.patch to compatibility_version
  - Map VERSION major.minor.patch to current_version
  - See issue #4383.


Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.61
retrieving revision 1.62
diff -C 2 -d -r1.61 -r1.62
*** cmMakefileLibraryTargetGenerator.cxx	11 Apr 2008 17:13:15 -0000	1.61
--- cmMakefileLibraryTargetGenerator.cxx	9 Jul 2008 14:09:46 -0000	1.62
***************
*** 365,368 ****
--- 365,376 ----
    this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
  
+   // Add OSX version flags, if any.
+   if(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
+      this->Target->GetType() == cmTarget::MODULE_LIBRARY)
+     {
+     this->AppendOSXVerFlag(linkFlags, linkLanguage, "COMPATIBILITY", true);
+     this->AppendOSXVerFlag(linkFlags, linkLanguage, "CURRENT", false);
+     }
+ 
    // Construct the name of the library.
    std::string targetName;
***************
*** 906,907 ****
--- 914,949 ----
                            libCleanFiles.begin(),libCleanFiles.end());
  }
+ 
+ //----------------------------------------------------------------------------
+ void
+ cmMakefileLibraryTargetGenerator
+ ::AppendOSXVerFlag(std::string& flags, const char* lang,
+                    const char* name, bool so)
+ {
+   // Lookup the flag to specify the version.
+   std::string fvar = "CMAKE_";
+   fvar += lang;
+   fvar += "_OSX_";
+   fvar += name;
+   fvar += "_VERSION_FLAG";
+   const char* flag = this->Makefile->GetDefinition(fvar.c_str());
+ 
+   // Skip if no such flag.
+   if(!flag)
+     {
+     return;
+     }
+ 
+   // Lookup the target version information.
+   int major;
+   int minor;
+   int patch;
+   this->Target->GetTargetVersion(so, major, minor, patch);
+   if(major > 0 || minor > 0 || patch > 0)
+     {
+     // Append the flag since a non-zero version is specified.
+     cmOStringStream vflag;
+     vflag << flag << major << "." << minor << "." << patch;
+     this->LocalGenerator->AppendFlags(flags, vflag.str().c_str());
+     }
+ }

Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.194
retrieving revision 1.195
diff -C 2 -d -r1.194 -r1.195
*** cmGlobalXCodeGenerator.cxx	7 Jul 2008 17:12:21 -0000	1.194
--- cmGlobalXCodeGenerator.cxx	9 Jul 2008 14:09:46 -0000	1.195
***************
*** 1460,1467 ****
      buildSettings->AddAttribute("LIBRARY_STYLE",
                                  this->CreateString("DYNAMIC"));
-     buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
-                                 this->CreateString("1"));
-     buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
-                                 this->CreateString("1"));
      break;
      }
--- 1460,1463 ----
***************
*** 1681,1684 ****
--- 1677,1712 ----
                                  "-Wmost -Wno-four-char-constants"
                                  " -Wno-unknown-pragmas"));
+ 
+   // Runtime version information.
+   if(target.GetType() == cmTarget::SHARED_LIBRARY)
+     {
+     int major;
+     int minor;
+     int patch;
+ 
+     // VERSION -> current_version
+     target.GetTargetVersion(false, major, minor, patch);
+     if(major == 0 && minor == 0 && patch == 0)
+       {
+       // Xcode always wants at least 1.0.0
+       major = 1;
+       }
+     cmOStringStream v;
+     v << major << "." << minor << "." << patch;
+     buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
+                                 this->CreateString(v.str().c_str()));
+ 
+     // SOVERSION -> compatibility_version
+     target.GetTargetVersion(true, major, minor, patch);
+     if(major == 0 && minor == 0 && patch == 0)
+       {
+       // Xcode always wants at least 1.0.0
+       major = 1;
+       }
+     cmOStringStream vso;
+     vso << major << "." << minor << "." << patch;
+     buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
+                                 this->CreateString(vso.str().c_str()));
+     }
  }
  

Index: cmMakefileLibraryTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmMakefileLibraryTargetGenerator.h	8 Apr 2008 04:06:46 -0000	1.7
--- cmMakefileLibraryTargetGenerator.h	9 Jul 2008 14:09:46 -0000	1.8
***************
*** 42,45 ****
--- 42,48 ----
    // Store the computd framework version for OS X Frameworks.
    std::string FrameworkVersion;
+ 
+   void AppendOSXVerFlag(std::string& flags, const char* lang,
+                         const char* name, bool so);
  };
  



More information about the Cmake-commits mailing list