mirror of
https://github.com/curl/curl.git
synced 2026-08-25 19:23:32 +03:00
cmke: add *_USE_STATIC_LIBS options for 9 dependencies
Via options: - `BROTLI_USE_STATIC_LIBS` - `CARES_USE_STATIC_LIBS` - `LIBSSH_USE_STATIC_LIBS` - `LIBSSH2_USE_STATIC_LIBS` - `MBEDTLS_USE_STATIC_LIBS` - `NGHTTP2_USE_STATIC_LIBS` - `NGHTTP3_USE_STATIC_LIBS` - `NGTCP2_USE_STATIC_LIBS` - `ZSTD_USE_STATIC_LIBS` When enabled, make a "best effort" finding static libs first and set the "build static" macro (on Windows) as required by the dependency. When doing `pkg-config`-based detections, make curl select the static configuration, which shall set the "build static" macro also. These options resemble CMake's `OPENSSL_USE_STATIC_LIBS` and `ZLIB_USE_STATIC_LIBS` (the latter does not support `pkg-config` as of CMake v4.2.2). Shared/static library selection based on loose filename conventions is fragile and prone to break if the non-static-suffixed library is found and happens to be a shared library, or, if the linker decides to pick up a shared copy (e.g. `.a.dll`) that shadows the static one. It may help to provide either static or shared, but not both, on the disk, and match that with this setting. Experimental. Ref: #20013 Closes #20015
This commit is contained in:
parent
3aa4fbf2d4
commit
26c39d8df1
10 changed files with 178 additions and 56 deletions
|
|
@ -25,14 +25,15 @@
|
|||
#
|
||||
# Input variables:
|
||||
#
|
||||
# - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory.
|
||||
# - `LIBSSH_LIBRARY`: Absolute path to `libssh` library.
|
||||
# - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory.
|
||||
# - `LIBSSH_LIBRARY`: Absolute path to `libssh` library.
|
||||
# - `LIBSSH_USE_STATIC_LIBS`: Configure for static libssh libraries.
|
||||
#
|
||||
# Defines:
|
||||
#
|
||||
# - `LIBSSH_FOUND`: System has libssh.
|
||||
# - `LIBSSH_VERSION`: Version of libssh.
|
||||
# - `CURL::libssh`: libssh library target.
|
||||
# - `LIBSSH_FOUND`: System has libssh.
|
||||
# - `LIBSSH_VERSION`: Version of libssh.
|
||||
# - `CURL::libssh`: libssh library target.
|
||||
|
||||
set(_libssh_pc_requires "libssh")
|
||||
|
||||
|
|
@ -47,10 +48,21 @@ if(_libssh_FOUND)
|
|||
set(Libssh_FOUND TRUE)
|
||||
set(LIBSSH_FOUND TRUE)
|
||||
set(LIBSSH_VERSION ${_libssh_VERSION})
|
||||
if(LIBSSH_USE_STATIC_LIBS)
|
||||
set(_libssh_CFLAGS "${_libssh_STATIC_CFLAGS}")
|
||||
set(_libssh_INCLUDE_DIRS "${_libssh_STATIC_INCLUDE_DIRS}")
|
||||
set(_libssh_LIBRARY_DIRS "${_libssh_STATIC_LIBRARY_DIRS}")
|
||||
set(_libssh_LIBRARIES "${_libssh_STATIC_LIBRARIES}")
|
||||
endif()
|
||||
message(STATUS "Found Libssh (via pkg-config): ${_libssh_INCLUDE_DIRS} (found version \"${LIBSSH_VERSION}\")")
|
||||
else()
|
||||
find_path(LIBSSH_INCLUDE_DIR NAMES "libssh/libssh.h")
|
||||
find_library(LIBSSH_LIBRARY NAMES "ssh" "libssh")
|
||||
if(LIBSSH_USE_STATIC_LIBS)
|
||||
set(_libssh_CFLAGS "-DLIBSSH_STATIC")
|
||||
find_library(LIBSSH_LIBRARY NAMES "ssh_static" "libssh_static" "ssh" "libssh")
|
||||
else()
|
||||
find_library(LIBSSH_LIBRARY NAMES "ssh" "libssh")
|
||||
endif()
|
||||
|
||||
unset(LIBSSH_VERSION CACHE)
|
||||
if(LIBSSH_INCLUDE_DIR AND EXISTS "${LIBSSH_INCLUDE_DIR}/libssh/libssh_version.h")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue