diff --git a/CMake/FindGSS.cmake b/CMake/FindGSS.cmake index 2dfc9ff4db..94fdc5f5db 100644 --- a/CMake/FindGSS.cmake +++ b/CMake/FindGSS.cmake @@ -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() diff --git a/CMake/FindMSH3.cmake b/CMake/FindMSH3.cmake index 92e6c3ef07..387d30b24e 100644 --- a/CMake/FindMSH3.cmake +++ b/CMake/FindMSH3.cmake @@ -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() diff --git a/CMake/FindMbedTLS.cmake b/CMake/FindMbedTLS.cmake index 8db6eb367e..e361c9636a 100644 --- a/CMake/FindMbedTLS.cmake +++ b/CMake/FindMbedTLS.cmake @@ -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() diff --git a/CMake/FindRustls.cmake b/CMake/FindRustls.cmake index 0e065b0022..db0e153f3b 100644 --- a/CMake/FindRustls.cmake +++ b/CMake/FindRustls.cmake @@ -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() diff --git a/CMakeLists.txt b/CMakeLists.txt index fc44cca2db..0a0f2d1bf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -636,7 +636,7 @@ if(CURL_USE_MBEDTLS) set(USE_MBEDTLS ON) list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES}) list(APPEND CURL_LIBDIRS ${MBEDTLS_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "mbedtls") + list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${MBEDTLS_PC_REQUIRES}) include_directories(SYSTEM ${MBEDTLS_INCLUDE_DIRS}) link_directories(${MBEDTLS_LIBRARY_DIRS}) if(MBEDTLS_CFLAGS) @@ -726,7 +726,7 @@ if(CURL_USE_RUSTLS) set(USE_RUSTLS ON) list(APPEND CURL_LIBS ${RUSTLS_LIBRARIES}) list(APPEND CURL_LIBDIRS ${RUSTLS_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "rustls") + list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${RUSTLS_PC_REQUIRES}) include_directories(SYSTEM ${RUSTLS_INCLUDE_DIRS}) link_directories(${RUSTLS_LIBRARY_DIRS}) if(RUSTLS_CFLAGS) @@ -952,7 +952,7 @@ if(USE_MSH3) find_package(MSH3 REQUIRED) list(APPEND CURL_LIBS ${MSH3_LIBRARIES}) list(APPEND CURL_LIBDIRS ${MSH3_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libmsh3") + list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${MSH3_PC_REQUIRES}) include_directories(SYSTEM ${MSH3_INCLUDE_DIRS}) link_directories(${MSH3_LIBRARY_DIRS}) if(MSH3_CFLAGS) @@ -1041,7 +1041,8 @@ if(NOT CURL_DISABLE_LDAP) list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DLDAP_DEPRECATED=1") list(APPEND CMAKE_REQUIRED_LIBRARIES ${LDAP_LIBRARY}) set(CURL_LIBS "${LDAP_LIBRARY};${CURL_LIBS}") - set(LIBCURL_PC_REQUIRES_PRIVATE "ldap;${LIBCURL_PC_REQUIRES_PRIVATE}") + # FIXME: uncomment once pkg-config-based detection landed: https://github.com/curl/curl/pull/15273 + # set(LIBCURL_PC_REQUIRES_PRIVATE "${LDAP_PC_REQUIRES};${LIBCURL_PC_REQUIRES_PRIVATE}") if(HAVE_LIBLBER) list(APPEND CMAKE_REQUIRED_LIBRARIES ${LDAP_LBER_LIBRARY}) set(CURL_LIBS "${LDAP_LBER_LIBRARY};${CURL_LIBS}") @@ -1248,13 +1249,7 @@ if(CURL_USE_GSSAPI) list(APPEND CURL_LIBS ${GSS_LIBRARIES}) list(APPEND CURL_LIBDIRS ${GSS_LIBRARY_DIRS}) - if(GSS_FLAVOUR STREQUAL "GNU") - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "gss") - elseif(GSS_FLAVOUR STREQUAL "MIT") - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "mit-krb5-gssapi") - else() # Heimdal - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "heimdal-gssapi") - endif() + list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${GSS_PC_REQUIRES}) include_directories(SYSTEM ${GSS_INCLUDE_DIRS}) link_directories(${GSS_LIBRARY_DIRS}) if(GSS_CFLAGS) diff --git a/acinclude.m4 b/acinclude.m4 index 0c17ba5ec5..c750ed2172 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -565,7 +565,9 @@ AC_DEFUN([CURL_CHECK_LIBS_LDAP], [ else LIBS="$curl_cv_ldap_LIBS $curl_cv_save_LIBS" fi - LIBCURL_PC_REQUIRES_PRIVATE="ldap $LIBCURL_PC_REQUIRES_PRIVATE" + if false; then + LIBCURL_PC_REQUIRES_PRIVATE="ldap $LIBCURL_PC_REQUIRES_PRIVATE" + fi AC_MSG_RESULT([$curl_cv_ldap_LIBS]) ;; esac diff --git a/configure.ac b/configure.ac index c83d35689e..090c6757ab 100644 --- a/configure.ac +++ b/configure.ac @@ -2015,12 +2015,14 @@ if test x"$want_gss" = xyes; then AC_DEFINE(HAVE_GSSAPI, 1, [if you have GSS-API libraries]) HAVE_GSSAPI=1 curl_gss_msg="enabled (MIT Kerberos/Heimdal)" + link_pkgconfig='' if test -n "$gnu_gss"; then curl_gss_msg="enabled (GNU GSS)" LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR" LDFLAGSPC="$LDFLAGSPC $GSSAPI_LIB_DIR" LIBS="-lgss $LIBS" + link_pkgconfig=1 elif test -z "$GSSAPI_LIB_DIR"; then case $host in *-apple-*) @@ -2040,11 +2042,13 @@ if test x"$want_gss" = xyes; then elif test "$PKGCONFIG" != "no"; then gss_libs=`$PKGCONFIG --libs mit-krb5-gssapi` LIBS="$gss_libs $LIBS" + link_pkgconfig=1 elif test -f "$KRB5CONFIG"; then dnl krb5-config doesn't have --libs-only-L or similar, put everything dnl into LIBS gss_libs=`$KRB5CONFIG --libs gssapi` LIBS="$gss_libs $LIBS" + link_pkgconfig=1 else case $host in *-hp-hpux*) @@ -2077,12 +2081,14 @@ if test x"$want_gss" = xyes; then ;; esac fi - if test -n "$gnu_gss"; then - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE gss" - elif test "x$not_mit" = "x1"; then - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE heimdal-gssapi" - else - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE mit-krb5-gssapi" + if test -n "$link_pkgconfig"; then + if test -n "$gnu_gss"; then + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE gss" + elif test "x$not_mit" = "x1"; then + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE heimdal-gssapi" + else + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE mit-krb5-gssapi" + fi fi else CPPFLAGS="$save_CPPFLAGS" @@ -3761,7 +3767,9 @@ if test X"$want_msh3" != Xno; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_MSH3" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $DIR_MSH3 to CURL_LIBRARY_PATH]) - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE libmsh3" + if false; then + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE libmsh3" + fi experimental="$experimental HTTP3" ) ], diff --git a/m4/curl-mbedtls.m4 b/m4/curl-mbedtls.m4 index 282ed06055..73befc3f86 100644 --- a/m4/curl-mbedtls.m4 +++ b/m4/curl-mbedtls.m4 @@ -104,7 +104,9 @@ if test "x$OPT_MBEDTLS" != xno; then AC_MSG_NOTICE([Added $mbedtlslib to CURL_LIBRARY_PATH]) fi fi - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE mbedtls" + if false; then + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE mbedtls" + fi fi fi dnl mbedTLS not disabled diff --git a/m4/curl-rustls.m4 b/m4/curl-rustls.m4 index 57cec768aa..f91f0f423c 100644 --- a/m4/curl-rustls.m4 +++ b/m4/curl-rustls.m4 @@ -112,6 +112,8 @@ if test "x$OPT_RUSTLS" != xno; then ;; esac + link_pkgconfig='' + if test "$PKGTEST" = "yes"; then CURL_CHECK_PKGCONFIG(rustls, [$RUSTLS_PCDIR]) @@ -140,6 +142,7 @@ if test "x$OPT_RUSTLS" != xno; then dnl additional libs may be necessary. Hope that we dnl don't need any. LIBS="$SSL_LIBS $LIBS" + link_pkgconfig=1 ssl_msg="rustls" AC_DEFINE(USE_RUSTLS, 1, [if Rustls is enabled]) AC_SUBST(USE_RUSTLS, [1]) @@ -176,7 +179,9 @@ if test "x$OPT_RUSTLS" != xno; then AC_MSG_NOTICE([Added $LIB_RUSTLS to CURL_LIBRARY_PATH]) fi fi - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE rustls" + if test -n "$link_pkgconfig"; then + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE rustls" + fi fi test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"