Merge bitcoin-core/secp256k1#1685: cmake: Emulate Libtool's behavior on FreeBSD

37dd422b5c cmake: Emulate Libtool's behavior on FreeBSD (Hennadii Stepanov)

Pull request description:

  Building the master branch @ f24b838bed on FreeBSD 14.3:
  - with Autotools:
  ```
  $ ./autogen.sh
  $ ./configure --disable-static --prefix /tmp/AUTOTOOLS
  $ gmake
  $ gmake install
  $ tree /tmp/AUTOTOOLS/lib
  /tmp/AUTOTOOLS/lib
  ├── libsecp256k1.la
  ├── libsecp256k1.so -> libsecp256k1.so.5.0.1
  ├── libsecp256k1.so.5 -> libsecp256k1.so.5.0.1
  ├── libsecp256k1.so.5.0.1
  └── pkgconfig
      └── libsecp256k1.pc

  2 directories, 5 files
  ```
  - with CMake:
  ```
  $ cmake -B build -DCMAKE_INSTALL_PREFIX=/tmp/CMAKE
  $ cmake --build build
  $ cmake --install build
  $ tree /tmp/CMAKE/lib
  /tmp/CMAKE/lib
  ├── cmake
  │   └── libsecp256k1
  │       ├── libsecp256k1-config-version.cmake
  │       ├── libsecp256k1-config.cmake
  │       ├── libsecp256k1-targets-relwithdebinfo.cmake
  │       └── libsecp256k1-targets.cmake
  ├── libsecp256k1.so -> libsecp256k1.so.5
  ├── libsecp256k1.so.5
  └── pkgconfig
      └── libsecp256k1.pc

  4 directories, 7 files
  ```

  With this PR:
  ```
  $ cmake -B build -DCMAKE_INSTALL_PREFIX=/tmp/CMAKE+PR
  $ cmake --build build
  $ cmake --install build
  $ tree /tmp/CMAKE+PR/lib
  /tmp/CMAKE+PR/lib
  ├── cmake
  │   └── libsecp256k1
  │       ├── libsecp256k1-config-version.cmake
  │       ├── libsecp256k1-config.cmake
  │       ├── libsecp256k1-targets-relwithdebinfo.cmake
  │       └── libsecp256k1-targets.cmake
  ├── libsecp256k1.so -> libsecp256k1.so.5
  ├── libsecp256k1.so.5 -> libsecp256k1.so.5.0.1
  ├── libsecp256k1.so.5.0.1
  └── pkgconfig
      └── libsecp256k1.pc

  4 directories, 8 files
  ```

  From [FreeBSD Developers' Handbook](https://docs.freebsd.org/en/books/developers-handbook/policies/#policies-shlib):
  > If you are adding shared library support to a port or other piece of software that does not have one, the version numbers should follow these rules. Generally, the resulting numbers will have nothing to do with the release version of the software.
  >
  > For ports:
  >
  >    - Prefer using the number already selected by upstream
  >
  >    - If upstream provides symbol versioning, ensure that we use their script

ACKs for top commit:
  real-or-random:
    utACK 37dd422b5c

Tree-SHA512: b603d7e293ae1fb15c2b3c05957dcc3cbe94294083ad1d8cb00b06b0e295597fa09719d32c18d628670952b6d00467f5bc884be9ab791baf59ec265e26032470
This commit is contained in:
merge-script
2025-06-24 11:45:28 +02:00

View File

@@ -95,7 +95,7 @@ math(EXPR ${PROJECT_NAME}_soversion "${${PROJECT_NAME}_LIB_VERSION_CURRENT} - ${
set_target_properties(secp256k1 PROPERTIES
SOVERSION ${${PROJECT_NAME}_soversion}
)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$")
set_target_properties(secp256k1 PROPERTIES
VERSION ${${PROJECT_NAME}_soversion}.${${PROJECT_NAME}_LIB_VERSION_AGE}.${${PROJECT_NAME}_LIB_VERSION_REVISION}
)