gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
60 stars 50 forks source link

cmake build decreases the compatibility_version of the shared libraries vs autotools build #130

Open nieder opened 2 years ago

nieder commented 2 years ago

On macOS, the old autotools release (tested with 0.13.62) creates the library libzzip-0.13.dylib with a compatibility_version of 14.0.0. But the cmake build (tested with 0.13.72) has a compatibility_version of 13.0.0. This means that anything linked against 0.13.62 will fail if zziplib is upgraded to 0.13.72 because the compat_version decreased.

Setting MACHO_COMPATIBILITY_VERSION to 14.0.0 will fix this (or higher if new interfaces have been added between 0.13.62 and 0.13.72). This change does not affect the install_name (SOVERSION) of the library. And if the install_name for the libraries is ever increased, you can remove setting MACHO_COMPATIBILITY_VERSION because then SOVERSION will take precedence and it will a new one that autotools never saw.

https://cmake.org/cmake/help/git-stage/prop_tgt/MACHO_COMPATIBILITY_VERSION.html

Sample code change in zzip/CMakeLists.txt (but needs to be done for the 4 libraries)

 set_target_properties(libzzip PROPERTIES OUTPUT_NAME "zzip" RELEASE_POSTFIX "-${RELNUM}")
-SET_TARGET_PROPERTIES(libzzip PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
+SET_TARGET_PROPERTIES(libzzip PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM} MACHO_COMPATIBILITY_VERSION 14.0.0)
gdraheim commented 1 year ago

I am a bit hesitant as the feature was introduced in cmake 3.17 and that's the version that I have installed as latest on my system. Pretty new? I don't know about the current cmake support in the common distros around. May be that needs an ifelse() somehow ... and I am not sure if a liberal value is the way to go here. I will keep this patch open so that people are informed how to fix the mac issue if needed.

nieder commented 1 year ago

Latest upstream is 3.24.1. Don't know which distro is still carrying 3.17 (Debian stable is 3.18.4; Ubuntu Jammy is at 3.22), and 3.17 seems to have come out in 2020). This issue has been common when switching from autotools (libtool really) versioning to cmake versioning. Once the SOVERSION gets bumped in zziplib, then this will be moot.

nieder commented 1 year ago

To patch this locally, have any interfaces been added, removed, or changed between zziplib 0.13.62 and 0.13.72? This will help me figure out which way I should change MACHO_COMPATIBILITY_VERSION. Thanks.

ryandesign commented 4 months ago

Please finally fix this two-year-old issue.