cmake: add and use local FindGnuTLS module

Replacing a combination of custom logic in the main script and relying
on CMake's built-in Find module, with code and behavior used for
the rest of dependencies.

Also to:
- add version detection in the non-pkg-config path.
- make `GNUTLS_INCLUDE_DIR` and `GNUTLS_LIBRARY` take precedence over
  pkg-config. As with other dependencies.
- document the above two configuration options.
- prepare for #16973, which originally introduced this local Find
  module.

The local module is doing largely the same as CMake's built-in
FindGnuTLS. Differences:
- honors `CURL_USE_PKGCONFIG`.
- returns GnuTLS version for non-pkg-config detection.
- consistently returns `GNUTLS_VERSION`.
  (CMake's built-in uses s different name in <3.16.)
- CMake 3.16+ returns an imported target. curl supports 3.7,
  therefore we may only use it conditionally, which isn't worth it.

Cherry-picked from #16973

Closes #19163
This commit is contained in:
Viktor Szakats 2025-10-20 15:51:39 +02:00
parent 9e198618de
commit 1966c86d71
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
4 changed files with 99 additions and 17 deletions

View file

@ -404,6 +404,8 @@ Details via CMake
- `CARES_INCLUDE_DIR`: The c-ares include directory.
- `CARES_LIBRARY`: Path to `cares` library.
- `DL_LIBRARY`: Path to `dl` library. (for Rustls)
- `GNUTLS_INCLUDE_DIR`: The GnuTLS include directory.
- `GNUTLS_LIBRARY`: Path to `gnutls` library.
- `GSS_ROOT_DIR`: Set this variable to the root installation of GSS. (also supported as environment)
- `LDAP_INCLUDE_DIR`: The LDAP include directory.
- `LDAP_LIBRARY`: Path to `ldap` library.