This is a continuation of #1685.
Additionally, the logic has been factored out into its own module and the documentation has been also improved.
Here are GHA jobs that show ABI versioning: https://github.com/hebasto/secp256k1/actions/runs/27071316706.
Undrafted.
Concept ACK
0 | @@ -0,0 +1,28 @@ 1 | +# This emulates Libtool to make sure Libtool and CMake agree on the ABI version, 2 | +# see below "Calculate the version variables" in autotools-aux/ltmain.sh. 3 | +function(secp256k1_set_libtool_abi_version target current revision age)
naming: All other custom functions in cmake/ don't have the secp256k1_ prefix and the filename matches the function name.
This PR refactors CMake-side shared library ABI/version handling into a dedicated module and extends the Libtool-compatibility logic to cover NetBSD and OpenBSD, continuing the work from #1685 to keep Autotools/Libtool and CMake installs consistent.
Changes:
cmake/LibtoolCompatibleABI.cmake module.secp256k1 target to use the new helper function rather than inline platform conditionals.Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/CMakeLists.txt |
Replaces inline ABI/version property logic with a call into the new Libtool-compatibility module. |
cmake/LibtoolCompatibleABI.cmake |
New helper implementing per-OS ABI/version property rules (Linux/FreeBSD/NetBSD/OpenBSD/macOS/Windows). |
💡 <a href="/bitcoin-core/secp256k1/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
31 | + elseif(APPLE) 32 | + math(EXPR _compatibility "${current} + 1") 33 | + set_target_properties(${target} PROPERTIES 34 | + MACHO_COMPATIBILITY_VERSION ${_compatibility} 35 | + MACHO_CURRENT_VERSION ${_compatibility}.${revision} 36 | + )
On Apple, the previous logic always set SOVERSION (computed from current - age) before applying Mach-O version properties. In the new helper function the Apple branch sets only MACHO_* properties, so SOVERSION is no longer set, which can change the installed dylib name/symlink layout and break the goal of keeping Libtool and CMake ABI versioning aligned.
Hm, the LLM has a point:
For shared libraries, the MACHO_COMPATIBILITY_VERSION and MACHO_CURRENT_VERSION properties can be used to override the compatibility version and current version respectively. Note that SOVERSION will still be used to form the install_name and both SOVERSION and VERSION may also affect the file and symlink names.
0 | @@ -0,0 +1,51 @@ 1 | +# This emulates Libtool to make sure Libtool and CMake agree on the ABI version. 2 | +# The `version_type` variable is set in autotools-aux/m4/libtool.m4. 3 | +# For the `major` and `versuffix` variables, see below "Calculate the version 4 | +# variables" in autotools-aux/ltmain.sh.
The header comment points readers to autotools-aux/m4/libtool.m4 and autotools-aux/ltmain.sh, but those files are not present in the repository checkout (they are typically generated/installed by autoreconf). Consider clarifying that these files are produced by the Autotools bootstrap step so the references are actionable for someone reading the source tree.
The recent feedback has been addressed.
Here are GHA jobs that show ABI versioning on OpenBSD, NetBSD and macOS: https://github.com/hebasto/secp256k1/actions/runs/27205923502.