From: Daniel Stenberg Date: Sat, 3 Dec 2022 12:20:14 +0000 (+0100) Subject: cmake: set the soname on the shared library X-Git-Tag: curl-7_87_0~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5de6848f104d7cb0017080e31216265ac19d0dde;p=thirdparty%2Fcurl.git cmake: set the soname on the shared library Set SONAME and VERSION for platforms we think this works on. Remove issue from KNOWN_BUGS. Assisted-by: Jakub Zakrzewski Closes #10023 --- diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS index 502e84b12d..cbf5be352a 100644 --- a/docs/KNOWN_BUGS +++ b/docs/KNOWN_BUGS @@ -106,7 +106,6 @@ problems may have been fixed or changed somewhat since this was written. 13.2 Trying local ports fails on Windows 15. CMake - 15.1 use correct SONAME 15.2 support build with GnuTLS 15.3 unusable tool_hugehelp.c with MinGW 15.4 build docs/curl.1 @@ -711,13 +710,6 @@ problems may have been fixed or changed somewhat since this was written. 15. CMake -15.1 use correct SONAME - - The autotools build sets the SONAME properly according to VERSIONINFO in - lib/Makefile.am and so should cmake to make comparable build. - - See https://github.com/curl/curl/pull/5935 - 15.2 support build with GnuTLS 15.3 unusable tool_hugehelp.c with MinGW diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8cea346c34..5ca5357d9b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -98,11 +98,37 @@ endif() target_link_libraries(${LIB_NAME} PRIVATE ${CURL_LIBS}) +transform_makefile_inc("Makefile.soname" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake") +include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake) + set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL OUTPUT_NAME ${LIBCURL_OUTPUT_NAME} ) +if(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR + CMAKE_SYSTEM_NAME STREQUAL "Linux" OR + CMAKE_SYSTEM_NAME STREQUAL "GNU/kFreeBSD" OR + + # FreeBSD comes with the a.out and elf flavours + # but a.out was supported up to version 3.x and + # elf from 3.x. I cannot imagine someone runnig + # CMake on those ancient systems + CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR + + CMAKE_SYSTEM_NAME STREQUAL "Haiku") + + math(EXPR CMAKESONAME "${VERSIONCHANGE} - ${VERSIONDEL}") + set(CMAKEVERSION "${CMAKESONAME}.${VERSIONDEL}.${VERSIONADD}") + + set_target_properties(${LIB_NAME} PROPERTIES + VERSION ${CMAKEVERSION} + SOVERSION ${CMAKESONAME} + ) + +endif() + + if(HIDES_CURL_PRIVATE_SYMBOLS) set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS") set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE}) diff --git a/lib/Makefile.am b/lib/Makefile.am index e74ce1f0db..033b4bf102 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -28,7 +28,8 @@ CMAKE_DIST = CMakeLists.txt curl_config.h.cmake EXTRA_DIST = Makefile.mk config-win32.h config-win32ce.h config-plan9.h \ config-riscos.h config-mac.h curl_config.h.in config-dos.h \ libcurl.plist libcurl.rc config-amigaos.h config-win32ce.h \ - config-os400.h setup-os400.h $(CMAKE_DIST) setup-win32.h .checksrc + config-os400.h setup-os400.h $(CMAKE_DIST) setup-win32.h .checksrc \ + Makefile.soname lib_LTLIBRARIES = libcurl.la @@ -57,19 +58,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \ # Prevent LIBS from being used for all link targets LIBS = $(BLANK_AT_MAKETIME) -VERSIONINFO=-version-info 12:0:8 -# This flag accepts an argument of the form current[:revision[:age]]. So, -# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to -# 1. -# -# Here's the simplified rule guide on how to change -version-info: -# (current version is C:R:A) -# -# 1. if there are only source changes, use C:R+1:A -# 2. if interfaces were added use C+1:0:A+1 -# 3. if interfaces were removed, then use C+1:0:0 -# -# For the full guide on libcurl ABI rules, see docs/libcurl/ABI +include Makefile.soname AM_CPPFLAGS += -DBUILDING_LIBCURL AM_LDFLAGS = diff --git a/lib/Makefile.soname b/lib/Makefile.soname new file mode 100644 index 0000000000..2c6cfdea6c --- /dev/null +++ b/lib/Makefile.soname @@ -0,0 +1,42 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 1998 - 2022, Daniel Stenberg, , et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +# SPDX-License-Identifier: curl +# +########################################################################### + +VERSIONCHANGE=12 +VERSIONADD=0 +VERSIONDEL=8 + +# libtool version: +VERSIONINFO=-version-info $(VERSIONCHANGE):$(VERSIONADD):$(VERSIONDEL) +# This flag accepts an argument of the form current[:revision[:age]]. So, +# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to +# 1. +# +# Here's the simplified rule guide on how to change -version-info: +# (current version is C:R:A) +# +# 1. if there are only source changes, use C:R+1:A +# 2. if interfaces were added use C+1:0:A+1 +# 3. if interfaces were removed, then use C+1:0:0 +# +# For the full guide on libcurl ABI rules, see docs/libcurl/ABI