mirror of
https://github.com/curl/curl.git
synced 2026-08-26 08:33:31 +03:00
build: omit certain deps from libcurl.pc unless found via pkg-config
The idea of linking dependencies found to `libcurl.pc` turns out not to work in practice in some cases. Specifically: gss, ldap, mbedtls, libmsh3, rustls A `.pc` may not work or be missing for a couple of reasons: - not all build methods generate it: mbedTLS, Rustls - generated file is broken: msh3 Ref: https://github.com/nibanks/msh3/pull/225 - installed package flavour isn't shipping with one: FreeBSD GSS, OmniOS LDAP, macOS LDAP The effect of such issues shall be subtle in theory, because `libcurl.pc` normally lists these dependencies in the `Requires.private` section meant for static linking. But, e.g. `pkg-config --exists` requires these to be present, and builds sometimes use this check regardless of build type. This bug is not present in `pkgconf`; it only checks for them when `--static` is also passed. Fix these by adding affected `.pc` references to `libcurl.pc` only when we detected the dependency via `pkg-config`. There are a few side-effects of this solution: - references are never added for dependencies where curl doesn't implement `pkg-config` detection. These are: - autotools: ldap, mbedtls, msh3 - cmake: ldap (pending #15273) - generated `libcurl.pc` depends on the build-time environment. - generated `libcurl.pc` depends on curl build tool (cmake, autotools). - generated `libcurl.pc` depends on curl build implementation details. Make an exception for GNU GSS, where I blindly guess that `gss.pc` is always available, as no issues were reported. Other, not mentioned, dependencies continue to be added regardless of the detection method. Reported-by: Harmen Stoppels, Thomas, Daniel Engberg, Andy Fiddaman Fixes #15469 Fixes #15507 Fixes #15535 Fixes https://github.com/curl/curl/pull/15163#issuecomment-2473358444 Closes #15573
This commit is contained in:
parent
e0e93d4314
commit
d511ec8b0a
9 changed files with 44 additions and 21 deletions
|
|
@ -34,6 +34,7 @@
|
|||
# - `GSS_INCLUDE_DIRS`: The GSS include directories.
|
||||
# - `GSS_LIBRARIES`: The GSS library names.
|
||||
# - `GSS_LIBRARY_DIRS`: The GSS library directories.
|
||||
# - `GSS_PC_REQUIRES`: The GSS pkg-config packages.
|
||||
# - `GSS_CFLAGS`: Required compiler flags.
|
||||
# - `GSS_VERSION`: This is set to version advertised by pkg-config or read from manifest.
|
||||
# In case the library is found but no version info available it is set to "unknown"
|
||||
|
|
@ -212,6 +213,7 @@ if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional appr
|
|||
|
||||
if(_GSS_INCLUDE_DIRS)
|
||||
set(GSS_FLAVOUR "GNU")
|
||||
set(GSS_PC_REQUIRES "gss")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
@ -266,16 +268,19 @@ else()
|
|||
# _GSS_MODULE_NAME set since CMake 3.16
|
||||
if(_GSS_MODULE_NAME STREQUAL _gnu_modname OR _GSS_${_gnu_modname}_VERSION)
|
||||
set(GSS_FLAVOUR "GNU")
|
||||
set(GSS_PC_REQUIRES "gss")
|
||||
if(NOT _GSS_VERSION) # for old CMake versions?
|
||||
set(_GSS_VERSION ${_GSS_${_gnu_modname}_VERSION})
|
||||
endif()
|
||||
elseif(_GSS_MODULE_NAME STREQUAL _mit_modname OR _GSS_${_mit_modname}_VERSION)
|
||||
set(GSS_FLAVOUR "MIT")
|
||||
set(GSS_PC_REQUIRES "mit-krb5-gssapi")
|
||||
if(NOT _GSS_VERSION) # for old CMake versions?
|
||||
set(_GSS_VERSION ${_GSS_${_mit_modname}_VERSION})
|
||||
endif()
|
||||
else()
|
||||
set(GSS_FLAVOUR "Heimdal")
|
||||
set(GSS_PC_REQUIRES "heimdal-gssapi")
|
||||
if(NOT _GSS_VERSION) # for old CMake versions?
|
||||
set(_GSS_VERSION ${_GSS_${_heimdal_modname}_VERSION})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
# - `MSH3_INCLUDE_DIRS`: The msh3 include directories.
|
||||
# - `MSH3_LIBRARIES`: The msh3 library names.
|
||||
# - `MSH3_LIBRARY_DIRS`: The msh3 library directories.
|
||||
# - `MSH3_PC_REQUIRES`: The msh3 pkg-config packages.
|
||||
# - `MSH3_CFLAGS`: Required compiler flags.
|
||||
# - `MSH3_VERSION`: Version of msh3.
|
||||
|
||||
|
|
@ -45,6 +46,7 @@ if(CURL_USE_PKGCONFIG AND
|
|||
endif()
|
||||
|
||||
if(MSH3_FOUND)
|
||||
set(MSH3_PC_REQUIRES "libmsh3")
|
||||
string(REPLACE ";" " " MSH3_CFLAGS "${MSH3_CFLAGS}")
|
||||
message(STATUS "Found MSH3 (via pkg-config): ${MSH3_INCLUDE_DIRS} (found version \"${MSH3_VERSION}\")")
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
# - `MBEDTLS_INCLUDE_DIRS`: The mbedTLS include directories.
|
||||
# - `MBEDTLS_LIBRARIES`: The mbedTLS library names.
|
||||
# - `MBEDTLS_LIBRARY_DIRS`: The mbedTLS library directories.
|
||||
# - `MBEDTLS_PC_REQUIRES`: The mbedTLS pkg-config packages.
|
||||
# - `MBEDTLS_CFLAGS`: Required compiler flags.
|
||||
# - `MBEDTLS_VERSION`: Version of mbedTLS.
|
||||
|
||||
|
|
@ -59,6 +60,7 @@ endif()
|
|||
if(MBEDTLS_FOUND AND MBEDX509_FOUND AND MBEDCRYPTO_FOUND)
|
||||
list(APPEND MBEDTLS_LIBRARIES ${MBEDX509_LIBRARIES} ${MBEDCRYPTO_LIBRARIES})
|
||||
list(REMOVE_DUPLICATES MBEDTLS_LIBRARIES)
|
||||
set(MBEDTLS_PC_REQUIRES "mbedtls")
|
||||
string(REPLACE ";" " " MBEDTLS_CFLAGS "${MBEDTLS_CFLAGS}")
|
||||
message(STATUS "Found MbedTLS (via pkg-config): ${MBEDTLS_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")")
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
# - `RUSTLS_INCLUDE_DIRS`: The Rustls include directories.
|
||||
# - `RUSTLS_LIBRARIES`: The Rustls library names.
|
||||
# - `RUSTLS_LIBRARY_DIRS`: The Rustls library directories.
|
||||
# - `RUSTLS_PC_REQUIRES`: The Rustls pkg-config packages.
|
||||
# - `RUSTLS_CFLAGS`: Required compiler flags.
|
||||
# - `RUSTLS_VERSION`: Version of Rustls.
|
||||
|
||||
|
|
@ -45,6 +46,7 @@ if(CURL_USE_PKGCONFIG AND
|
|||
endif()
|
||||
|
||||
if(RUSTLS_FOUND)
|
||||
set(RUSTLS_PC_REQUIRES "rustls")
|
||||
string(REPLACE ";" " " RUSTLS_CFLAGS "${RUSTLS_CFLAGS}")
|
||||
message(STATUS "Found Rustls (via pkg-config): ${RUSTLS_INCLUDE_DIRS} (found version \"${RUSTLS_VERSION}\")")
|
||||
else()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue