cmake: revert to pkg_check_modules()

Prefer `pkg_check_modules()` over `pkg_search_module()`.

`pkg_check_modules()` logs a line when there is a hit, and also warnings
if a sub-dependency is missing. In `QUIET` mode, both are silent.

The extra info is useful to see if a detection happened via
`pkg-config`.

Keep `pkg_search_module()` in `FindGSS`. We pass two dependencies
there and we want to keep stopping on the first one.

Partially reverts c2889a7b41 #14388

Closes #14573
This commit is contained in:
Viktor Szakats 2024-08-16 18:19:25 +02:00
parent 4beb236478
commit f3a03df6a1
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
15 changed files with 19 additions and 19 deletions

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_BROTLI "libbrotlidec")
pkg_check_modules(PC_BROTLI "libbrotlidec")
endif()
find_path(BROTLI_INCLUDE_DIR "brotli/decode.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_CARES "libcares")
pkg_check_modules(PC_CARES "libcares")
endif()
find_path(CARES_INCLUDE_DIR "ares.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_LIBPSL "libpsl")
pkg_check_modules(PC_LIBPSL "libpsl")
endif()
find_path(LIBPSL_INCLUDE_DIR "libpsl.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_LIBSSH2 "libssh2")
pkg_check_modules(PC_LIBSSH2 "libssh2")
endif()
find_path(LIBSSH2_INCLUDE_DIR "libssh2.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_MSH3 "libmsh3")
pkg_check_modules(PC_MSH3 "libmsh3")
endif()
find_path(MSH3_INCLUDE_DIR "msh3.h"

View File

@ -38,7 +38,7 @@ endif()
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_MBEDTLS "mbedtls")
pkg_check_modules(PC_MBEDTLS "mbedtls")
endif()
find_path(MBEDTLS_INCLUDE_DIR "mbedtls/ssl.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_NGHTTP2 "libnghttp2")
pkg_check_modules(PC_NGHTTP2 "libnghttp2")
endif()
find_path(NGHTTP2_INCLUDE_DIR "nghttp2/nghttp2.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_NGHTTP3 "libnghttp3")
pkg_check_modules(PC_NGHTTP3 "libnghttp3")
endif()
find_path(NGHTTP3_INCLUDE_DIR "nghttp3/nghttp3.h"

View File

@ -40,7 +40,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_NGTCP2 "libngtcp2")
pkg_check_modules(PC_NGTCP2 "libngtcp2")
endif()
find_path(NGTCP2_INCLUDE_DIR "ngtcp2/ngtcp2.h"
@ -80,7 +80,7 @@ if(NGTCP2_FIND_COMPONENTS)
if(NGTCP2_CRYPTO_BACKEND)
string(TOLOWER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library)
if(CURL_USE_PKGCONFIG)
pkg_search_module(PC_${_crypto_library} "lib${_crypto_library}")
pkg_check_modules(PC_${_crypto_library} "lib${_crypto_library}")
endif()
find_library(${_crypto_library}_LIBRARY NAMES ${_crypto_library}
HINTS

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(NETTLE "nettle")
pkg_check_modules(NETTLE "nettle")
endif()
if(NETTLE_FOUND)

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_QUICHE "quiche")
pkg_check_modules(PC_QUICHE "quiche")
endif()
find_path(QUICHE_INCLUDE_DIR "quiche.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_WOLFSSL QUIET "wolfssl")
pkg_check_modules(PC_WOLFSSL QUIET "wolfssl")
endif()
find_path(WolfSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_Zstd "libzstd")
pkg_check_modules(PC_Zstd "libzstd")
endif()
find_path(Zstd_INCLUDE_DIR "zstd.h"

View File

@ -32,7 +32,7 @@
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(PC_RUSTLS "rustls")
pkg_check_modules(PC_RUSTLS "rustls")
endif()
find_path(RUSTLS_INCLUDE_DIR "rustls.h"

View File

@ -605,7 +605,7 @@ endif()
if(CURL_USE_GNUTLS)
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(GNUTLS "gnutls")
pkg_check_modules(GNUTLS "gnutls")
if(GNUTLS_FOUND)
set(GNUTLS_LIBRARIES ${GNUTLS_LINK_LIBRARIES})
endif()
@ -1001,7 +1001,7 @@ if(USE_LIBIDN2)
if(NOT HAVE_LIBIDN2 OR NOT HAVE_IDN2_H)
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(LIBIDN2 "libidn2")
pkg_check_modules(LIBIDN2 "libidn2")
endif()
if(LIBIDN2_FOUND)
include_directories(${LIBIDN2_INCLUDE_DIRS})
@ -1082,7 +1082,7 @@ if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH)
message(STATUS "Found libssh ${libssh_VERSION}")
elseif(CURL_USE_PKGCONFIG)
find_package(PkgConfig QUIET)
pkg_search_module(LIBSSH "libssh")
pkg_check_modules(LIBSSH "libssh")
if(LIBSSH_FOUND)
include_directories(${LIBSSH_INCLUDE_DIRS})
endif()
@ -1120,7 +1120,7 @@ mark_as_advanced(CURL_USE_GSASL)
if(CURL_USE_GSASL)
if(CURL_USE_PKGCONFIG)
find_package(PkgConfig REQUIRED)
pkg_search_module(GSASL REQUIRED "libgsasl")
pkg_check_modules(GSASL REQUIRED "libgsasl")
else()
message(WARNING "GSASL has been requested but requires a platform with pkg-config support. Skipping.")
endif()