build: cmake multi-pkg-config detection improvements (brotli, ldap, mbedtls)

Apply downstream patch from the vcpkg project:

- cmake/FindBrotli: streamline detecting multiple pkg-config modules.
  Add `libbrotlicommon` to `Requires.private` in `libcurl.pc`.

Apply the above idea to the rest of multi-module dependencies:

- cmake/FindMbedTLS: streamline detecting multiple pkg-config modules
  Add `mbedx509`, `mbedcrypto` to `Requires.private` in `libcurl.pc`.

- cmake/FindLDAP: streamline detecting multiple pkg-config modules

And sync these changes with autotools, and add `libbrotlicommon`,
`mbedx509`, `mbedcrypto` to `Requires.private`.

Co-authored-by: Kai Pastor
Ref: https://github.com/microsoft/vcpkg/pull/43819

Closes #16479
This commit is contained in:
Viktor Szakats 2025-02-25 16:36:21 +01:00
parent f4831daa9b
commit 3b501976a9
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
5 changed files with 9 additions and 26 deletions

View file

@ -39,7 +39,7 @@
# - `LDAP_CFLAGS`: Required compiler flags.
# - `LDAP_VERSION`: Version of ldap.
set(LDAP_PC_REQUIRES "ldap")
set(LDAP_PC_REQUIRES "ldap" "lber")
if(CURL_USE_PKGCONFIG AND
NOT DEFINED LDAP_INCLUDE_DIR AND
@ -47,14 +47,9 @@ if(CURL_USE_PKGCONFIG AND
NOT DEFINED LDAP_LBER_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(LDAP ${LDAP_PC_REQUIRES})
pkg_check_modules(LDAP_LBER "lber")
endif()
if(LDAP_FOUND AND LDAP_LBER_FOUND)
list(APPEND LDAP_LIBRARIES ${LDAP_LBER_LIBRARIES})
list(REVERSE LDAP_LIBRARIES)
list(REMOVE_DUPLICATES LDAP_LIBRARIES)
list(REVERSE LDAP_LIBRARIES)
if(LDAP_FOUND)
string(REPLACE ";" " " LDAP_CFLAGS "${LDAP_CFLAGS}")
message(STATUS "Found LDAP (via pkg-config): ${LDAP_INCLUDE_DIRS} (found version \"${LDAP_VERSION}\")")
else()