mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 12:53:55 +08:00
macOS: Add OSX_COMPATIBILITY_VERSION and OSX_CURRENT_VERSION properties
Fixes: #17652
This commit is contained in:

committed by
Brad King

parent
f45b2c4812
commit
4a62e3d97c
@@ -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
|
||||
|
14
Help/prop_tgt/OSX_COMPATIBILITY_VERSION.rst
Normal file
14
Help/prop_tgt/OSX_COMPATIBILITY_VERSION.rst
Normal file
@@ -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.
|
13
Help/prop_tgt/OSX_CURRENT_VERSION.rst
Normal file
13
Help/prop_tgt/OSX_CURRENT_VERSION.rst
Normal file
@@ -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.
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
9
Help/release/dev/osx-version-flags.rst
Normal file
9
Help/release/dev/osx-version-flags.rst
Normal file
@@ -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.
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user