diff options
author | Isuru Fernando <isuruf@gmail.com> | 2020-01-24 16:32:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-01-24 19:13:41 (GMT) |
commit | 4a62e3d97c3ae907d9c43d139ff5bef55ef356aa (patch) | |
tree | 77ec7a313d4394a5416bde806ac0df8cab83b73b /Source | |
parent | f45b2c48129ce302d100b0965374bcaacbb74219 (diff) | |
download | CMake-4a62e3d97c3ae907d9c43d139ff5bef55ef356aa.zip CMake-4a62e3d97c3ae907d9c43d139ff5bef55ef356aa.tar.gz CMake-4a62e3d97c3ae907d9c43d139ff5bef55ef356aa.tar.bz2 |
macOS: Add OSX_COMPATIBILITY_VERSION and OSX_CURRENT_VERSION properties
Fixes: #17652
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 22 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 12 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 10 |
4 files changed, 36 insertions, 13 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 9106e70..b8d8b96 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -233,7 +233,10 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags, int major; int minor; int patch; - this->GeneratorTarget->GetTargetVersion(so, major, minor, patch); + std::string prop = cmStrCat("OSX_", name, "_VERSION"); + std::string fallback_prop = so ? "SOVERSION" : "VERSION"; + this->GeneratorTarget->GetTargetVersionFallback(prop, fallback_prop, major, + minor, patch); if (major > 0 || minor > 0 || patch > 0) { // Append the flag since a non-zero version is specified. std::ostringstream vflag; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 792cd4d..c525a6e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5280,11 +5280,23 @@ cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation( void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const { int patch; - this->GetTargetVersion(false, major, minor, patch); + this->GetTargetVersion("VERSION", major, minor, patch); } -void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major, - int& minor, int& patch) const +void cmGeneratorTarget::GetTargetVersionFallback( + const std::string& property, const std::string& fallback_property, + int& major, int& minor, int& patch) const +{ + if (this->GetProperty(property)) { + this->GetTargetVersion(property, major, minor, patch); + } else { + this->GetTargetVersion(fallback_property, major, minor, patch); + } +} + +void cmGeneratorTarget::GetTargetVersion(const std::string& property, + int& major, int& minor, + int& patch) const { // Set the default values. major = 0; @@ -5293,9 +5305,7 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major, assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); - // Look for a VERSION or SOVERSION property. - const char* prop = soversion ? "SOVERSION" : "VERSION"; - if (const char* version = this->GetProperty(prop)) { + if (const char* version = this->GetProperty(property)) { // Try to parse the version number and store the results that were // successfully parsed. int parsed_major; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9d06104..ac254c1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -755,11 +755,19 @@ public: void GetTargetVersion(int& major, int& minor) const; /** Get the target major, minor, and patch version numbers - interpreted from the VERSION or SOVERSION property. Version 0 + interpreted from the given property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(bool soversion, int& major, int& minor, + void GetTargetVersion(std::string const& property, int& major, int& minor, int& patch) const; + /** Get the target major, minor, and patch version numbers + interpreted from the given property and if empty use the + fallback property. Version 0 is returned if the property is + not set or cannot be parsed. */ + void GetTargetVersionFallback(const std::string& property, + const std::string& fallback_property, + int& major, int& minor, int& patch) const; + std::string GetFortranModuleDirectory(std::string const& working_dir) const; const char* GetSourcesProperty() const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f887284..da56f3f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2366,8 +2366,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, int minor; int patch; - // VERSION -> current_version - gtgt->GetTargetVersion(false, major, minor, patch); + // OSX_CURRENT_VERSION or VERSION -> current_version + gtgt->GetTargetVersionFallback("OSX_CURRENT_VERSION", "VERSION", major, + minor, patch); std::ostringstream v; // Xcode always wants at least 1.0.0 or nothing @@ -2377,8 +2378,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", this->CreateString(v.str())); - // SOVERSION -> compatibility_version - gtgt->GetTargetVersion(true, major, minor, patch); + // OSX_COMPATIBILITY_VERSION or SOVERSION -> compatibility_version + gtgt->GetTargetVersionFallback("OSX_COMPATIBILITY_VERSION", "SOVERSION", + major, minor, patch); std::ostringstream vso; // Xcode always wants at least 1.0.0 or nothing |