summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-properties.7.rst2
-rw-r--r--Help/prop_tgt/OSX_COMPATIBILITY_VERSION.rst14
-rw-r--r--Help/prop_tgt/OSX_CURRENT_VERSION.rst13
-rw-r--r--Help/prop_tgt/SOVERSION.rst10
-rw-r--r--Help/prop_tgt/VERSION.rst6
-rw-r--r--Help/release/dev/osx-version-flags.rst9
-rw-r--r--Source/cmCommonTargetGenerator.cxx5
-rw-r--r--Source/cmGeneratorTarget.cxx22
-rw-r--r--Source/cmGeneratorTarget.h12
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx10
10 files changed, 84 insertions, 19 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 393735e..d41fc15 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -300,6 +300,8 @@ Properties on Targets
/prop_tgt/OBJCXX_STANDARD_REQUIRED
/prop_tgt/OSX_ARCHITECTURES_CONFIG
/prop_tgt/OSX_ARCHITECTURES
+ /prop_tgt/OSX_CURRENT_VERSION
+ /prop_tgt/OSX_COMPATIBILITY_VERSION
/prop_tgt/OUTPUT_NAME_CONFIG
/prop_tgt/OUTPUT_NAME
/prop_tgt/PDB_NAME_CONFIG
diff --git a/Help/prop_tgt/OSX_COMPATIBILITY_VERSION.rst b/Help/prop_tgt/OSX_COMPATIBILITY_VERSION.rst
new file mode 100644
index 0000000..1694df1
--- /dev/null
+++ b/Help/prop_tgt/OSX_COMPATIBILITY_VERSION.rst
@@ -0,0 +1,14 @@
+OSX_COMPATIBILITY_VERSION
+-------------------------
+
+What current version number is this target for OSX.
+
+For shared libraries on Mach-O systems (e.g. macOS, iOS)
+the ``OSX_COMPATIBILITY_VERSION`` property correspond to
+``compatibility version`` and :prop_tgt:`OSX_CURRENT_VERSION` to
+``current version``.
+See the :prop_tgt:`FRAMEWORK` target property for an example.
+
+Versions of Mach-O binaries may be checked with the ``otool -L <binary>``
+command. If ``OSX_COMPATIBILITY_VERSION`` is not set, the value of
+the :prop_tgt:``SOVERSION`` property will be used.
diff --git a/Help/prop_tgt/OSX_CURRENT_VERSION.rst b/Help/prop_tgt/OSX_CURRENT_VERSION.rst
new file mode 100644
index 0000000..609924d
--- /dev/null
+++ b/Help/prop_tgt/OSX_CURRENT_VERSION.rst
@@ -0,0 +1,13 @@
+OSX_CURRENT_VERSION
+-------------------
+
+What current version number is this target for OSX.
+
+For shared libraries on Mach-O systems (e.g. macOS, iOS)
+the :prop_tgt:`OSX_COMPATIBILITY_VERSION` property correspond to
+``compatibility version`` and ``OSX_CURRENT_VERSION`` to ``current version``.
+See the :prop_tgt:`FRAMEWORK` target property for an example.
+
+Versions of Mach-O binaries may be checked with the ``otool -L <binary>``
+command. If ``OSX_CURRENT_VERSION`` is not set, the value of
+the :prop_tgt:``VERSION`` property will be used.
diff --git a/Help/prop_tgt/SOVERSION.rst b/Help/prop_tgt/SOVERSION.rst
index b07c17c..1a66c8f 100644
--- a/Help/prop_tgt/SOVERSION.rst
+++ b/Help/prop_tgt/SOVERSION.rst
@@ -21,7 +21,9 @@ Mach-O Versions
^^^^^^^^^^^^^^^
For shared libraries and executables on Mach-O systems (e.g. macOS, iOS),
-the ``SOVERSION`` property corresponds to *compatibility version* and
-:prop_tgt:`VERSION` to *current version*. See the :prop_tgt:`FRAMEWORK` target
-property for an example. Versions of Mach-O binaries may be checked with the
-``otool -L <binary>`` command.
+the ``SOVERSION`` property is a fallback to
+:prop_tgt:`OSX_COMPATIBILITY_VERSION` property which corresponds to
+*compatiblity version* and :prop_tgt:`VERSION` is a fallback to
+:prop_tgt:`OSX_CURRENT_VERSION` which corresponds to *current version*.
+See the :prop_tgt:`FRAMEWORK` target property for an example. Versions
+of Mach-O binaries may be checked with the ``otool -L <binary>`` command.
diff --git a/Help/prop_tgt/VERSION.rst b/Help/prop_tgt/VERSION.rst
index ff3b303..a24b613 100644
--- a/Help/prop_tgt/VERSION.rst
+++ b/Help/prop_tgt/VERSION.rst
@@ -23,7 +23,9 @@ Mach-O Versions
^^^^^^^^^^^^^^^
For shared libraries and executables on Mach-O systems (e.g. macOS, iOS),
-the :prop_tgt:`SOVERSION` property correspond to *compatibility version* and
-``VERSION`` to *current version*. See the :prop_tgt:`FRAMEWORK` target
+the ``VERSION`` property is a fallback to :prop_tgt:`OSX_CURRENT_VERSION`
+property which corresponds to *current version* and :prop_tgt:`SOVERSION`
+is a fallback to :prop_tgt:`OSX_COMPATIBILITY_VERSION` which corresponds
+to *compatiblity version*. See the :prop_tgt:`FRAMEWORK` target
property for an example. Versions of Mach-O binaries may be checked with the
``otool -L <binary>`` command.
diff --git a/Help/release/dev/osx-version-flags.rst b/Help/release/dev/osx-version-flags.rst
new file mode 100644
index 0000000..329aca3
--- /dev/null
+++ b/Help/release/dev/osx-version-flags.rst
@@ -0,0 +1,9 @@
+add_osx_compatiblity_property
+-----------------------------
+
+* Target properties :prop_tgt:`OSX_COMPATIBILITY_VERSION` and
+ :prop_tgt:`OSX_CURRENT_VERSION` were added to set the
+ ``compatibility_version`` and ``curent_version`` respectively
+ on macOS. For backwards compatibility, if these properties
+ are not set, :prop_tgt:`SOVERSION` and :prop_tgt:`VERSION`
+ are used respectively as fallbacks.
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