diff options
author | Brad King <brad.king@kitware.com> | 2008-07-09 14:09:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-07-09 14:09:46 (GMT) |
commit | 0d54001276a3123e35e20ee7240cdeffe401e7af (patch) | |
tree | 828cabfa28cb3dd6e02812502b1615a5d54fbf8b /Source/cmMakefileLibraryTargetGenerator.cxx | |
parent | da4f142cc12cf603f7d34562d558c0ed7bd65d5f (diff) | |
download | CMake-0d54001276a3123e35e20ee7240cdeffe401e7af.zip CMake-0d54001276a3123e35e20ee7240cdeffe401e7af.tar.gz CMake-0d54001276a3123e35e20ee7240cdeffe401e7af.tar.bz2 |
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.
Diffstat (limited to 'Source/cmMakefileLibraryTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a881391..03b9622 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -364,6 +364,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string linkFlags; 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; std::string targetNameSO; @@ -905,3 +913,37 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->CleanFiles.insert(this->CleanFiles.end(), 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()); + } +} |