Commit Graph

253 Commits

Author SHA1 Message Date
Viktor Szakats
01a8157997
cmake: tidy-ups and rebase fixups
- limit `SIZEOF_SA_FAMILY_T` detection to non-Windows.
- make sure `sys/socket.h` exists before detecting `SIZEOF_SA_FAMILY_T`.
- limit `mach_absolute_time()` detection to `APPLE`. Drop from Windows
  pre-cache.
- skip `HAVE_LIBSOCKET` detection for Windows, drop pre-cached value.
- drop redundant pre-cached `HAVE_LIBZ` for Windows.
- `curl_required_libpaths()`: stop accepting multiple arguments.
  To prepare for `CMAKE_REQUIRED_LINK_DIRECTORIES` support.
  Follow-up to 7bab201abe #15193
- GSS: fix recent rebase mistakes:
  - fix variable name.
  - do not add a header twice.
  Follow-up to 91d451b488 #15157
- GSS: quote a variable.

Closes #15271
2024-10-12 22:33:29 +02:00
Viktor Szakats
dfd36d3ee0
cmake: apply WIN32_LEAN_AND_MEAN to all feature checks
Enable `WIN32_LEAN_AND_MEAN` for all feature detections on Windows.

(Also drop it from individual detections.)

Cherry-picked from #15164
2024-10-11 17:57:03 +02:00
Viktor Szakats
8e34505776
cmake: untangle feature detection interdependencies
- reduce `check_include_file_concat()` use to those headers that either
  depend on a previously detected header, or another header or symbol
  detection depend on it.

- replace `check_symbol_exists()` with `check_function_exists()` for
  functions that are detected with `AC_CHECK_FUNCS()` in `./configure`.
  This makes `setmode()` no longer be detected with MSYS, syncing
  this with `./configure`. Instead `_setmode()` is used now also in
  CMake MSYS builds. This is consistent with Cygwin builds also.

- add comment about which header/symbol detection depends on what
  header. Based on `./configure` mainly.

- form `CURL_TEST_DEFINES` manually, and include only those macros which
  are actually used in `CMake/CurlTests.c`.

- change `curl_internal_test()` to use `CMAKE_REQUIRED_DEFINITIONS`,
  instead of `CMAKE_REQUIRED_FLAGS` to simplify the logic, and to allow
  dropping the latter macro completely.

- drop `windows.h` from header and symbol checks.

- `./configure`: add comment about whether `netinet/in6.h`, `sys/un.h`
  are indeed meant to be included for all detections. There is a chance
  they were added there by accident.

Detection resuls were cross-checked between
436bbbe7ab (master) and
48ff4694e608ccfdedf7ce5bab2b96d6b2c23cda (this PR), for CI GHA Linux,
Linux HTTP/3, non-native, macOS and Windows jobs.

Closes #15164
2024-10-11 17:44:45 +02:00
Viktor Szakats
6074e33509
cmake: add comments to feature check options applied globally
Add comments saying when we want values set in feature check option
variables to apply to all feature checks, globally. These are currently:
`ws2_32` and `socket` libraries, and `-D_WIN32_WINNT=` macro.

Also use `list(APPEND ...)` for the libraries to avoid overwriting
potentially existing values.

Cherry-picked from #15157
Closes #15253
2024-10-10 19:36:04 +02:00
Viktor Szakats
91519bfb74
cmake: use cmake_push_check_state() around feature checks
Enclose
`CMAKE_EXTRA_INCLUDE_FILES`,
`CMAKE_REQUIRED_DEFINITIONS`,
`CMAKE_REQUIRED_FLAGS`,
`CMAKE_REQUIRED_INCLUDES`,
`CMAKE_REQUIRED_LIBRARIES`,
`CMAKE_REQUIRED_LINK_OPTIONS`,
settings within `cmake_push_check_state()`/`cmake_pop_check_state()`
calls. It prevents spilling them into other feature checks. It also
replaces manual resets found in some places (which can have
the undesired side-effect of destroying values meant for global use.)

Cherry-picked from #15157
Closes #15251
2024-10-10 19:35:58 +02:00
Viktor Szakats
7bab201abe
cmake: add native pkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL
Also:
- detect and add required system libraries for Rustls on macOS and
  non-Windows.
- add Linux CMake jobs for the touched dependencies.
  Caveats:
  - MSH3 generates a broken `libmsh3.pc`, so needs manual config.
    Upstream PR: https://github.com/nibanks/msh3/pull/225
  - Rustls `.pc` file missing, so needs manual config.

An internal change worthy of mention is that we are using the lib path
and name information returned by `pkg-config` as-is. Meaning the libname
doesn't include the full path, like it's usual with native cmake
detection. The path comes separately and needs to be rolled separately.
For this we add it to targets via `link_directories()`. We also keep tab
of them in `CURL_LIBDIRS` and use that in `libcurl.pc`. Feature checks
also need to receive these paths. CMake doesn't offer
a `CMAKE_REQUIRED_*` variable for this purpose, only
a `CMAKE_REQUIRED_LINK_OPTIONS` accepting raw linker flags. Add a macro
to convert a list of paths to linker options to solve it. wolfSSL
requires this for now.

Closes #15193
2024-10-10 14:45:09 +02:00
Viktor Szakats
ae5351696f
cmake: tidy up detection C code
Closes #15195
2024-10-10 14:29:35 +02:00
Viktor Szakats
9e19a577eb
cmake: detect GNU GSS
Fix to set `HAVE_GSSGNU` when GNU GSS is detected.

Also set the appropriate `pkg-config` dependency and do version
detection for the GNU GSS flavour.

Tested with `pkg-config` and partly tested without. The latter case
picks up everything else but, in my env. This is likely not the last
word to implement this detection correctly for all build-cases.

GNU GSS doesn't seem to have a Homebrew formula and building
it locally needs manual tweaks to make finish successfully.

Also move a MIT-specific header detection into to MIT-specific `if`
branch.

Closes #15176
2024-10-08 11:49:17 +02:00
Viktor Szakats
e888069f5a
cmake: detect HAVE_NETINET_IN6_H, HAVE_CLOSESOCKET_CAMEL, HAVE_PROTO_BSDSOCKET_H
To sync with `./configure`.

- `HAVE_NETINET_IN6_H` is
  needed by HPE NonStop NSE and NSX systems.
  Follow-up to 76ebd54175 #2155

- `HAVE_CLOSESOCKET_CAMEL`, `HAVE_PROTO_BSDSOCKET_H`
  are for AmigaOS.
  (Note: `./configure` tries to detect these for all targets, cmake does
  it only for AmigaOS, to not inflate configure time.)

Closes #15172
2024-10-07 13:45:20 +02:00
Viktor Szakats
5e70566094
build: detect and use _setmode() with Cygwin/MSYS, also use on Windows
Before this patch `setmode()` was not detected with Cygwin/MSYS, because
it's a macro, not a function, and detection is looking for a function.

Switching to symbol detection doesn't work because it mis-detects it on
BSD systems which features a function with the same name but different
functionality and arguments.

Fix it by looking for a `_setmode()` function on Cygwin/MSYS, and use it
if available.

`_setmode()` is recommended over `setmode()` by Windows documentation so
use that on Windows too. It seems to be available on all supported
compilers, so omit detection.

https://learn.microsoft.com/cpp/c-runtime-library/reference/posix-setmode
https://learn.microsoft.com/cpp/c-runtime-library/reference/setmode

Officially Windows requires argument `_O_BINARY` with an underscore.
`O_BINARY` is also supported but bound to conditions. Continue to use it
for simplicity. Cygwin supports `O_BINARY` (no underscore).

Closes #15169
2024-10-07 12:31:21 +02:00
Daniel Stenberg
c72cefea0f
select: use poll() if existing, avoid poll() with no sockets
poll() on macOS 10.12 was deemed broken in 2016 when we discovered that
it misbehaves when provided with no sockets to wait for. The
HAVE_POLL_FINE is used to mark a poll() implementation that behaves
correctly: it *should* still wait the timeout time.

curl has therefore opted to use select() on Apple operating systems ever
since. To avoid the risk that this or other breakage cause problems.

However, using select() internally is also bad because it suffers from
problems when using file descriptors beyond 1024.

This change makes poll() used if it is present, but if there is no
sockets to wait for it avoids using poll() and instead falls back to
select() - but without any sockets to wait for there is no 1024 problem.

This removes all previous special-handling involving HAVE_POLL_FINE.

ref: https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/

Closes #15096
2024-10-01 15:11:50 +02:00
Stefan Eissing
97c0f89bd0
quic: use send/recvmmsg when available
add checks for sendmmsg in configure and CmakeLists.txt for enabling use
of these functions in ngtcp2/quiche quic.

Closes #14880
2024-09-30 08:51:16 +02:00
Daniel Stenberg
7060b9b082
build: fix cross-compile check for poll with bionic
Since it seems the _POSIX_C_SOURCE "trick" does not work there, the
check does not find poll().

Fixes #15013
Reported-by: vvb2060 on github
Closes #15037
2024-09-25 23:41:17 +02:00
Viktor Szakats
4619b4103b
build: fix possible -Wformat-overflow in lib557 with test bundle builds
- lib557: suppress `-Wformat-overflow` warning in source.
  Fixes:
  ```
  lib557.c: In function ‘test_float_formatting’:
  lib557.c:1408:37: error: ‘%*f’ directive output of 2147483648 bytes exceeds ‘INT_MAX’ [-Werror=format-overflow=]
   1408 |   curl_msnprintf(buf, sizeof(buf), "%*f", INT_MIN, 9.1);
        |                                     ^~~
  lib557.c:1408:3: note: ‘curl_msnprintf’ output 2147483649 bytes
   1408 |   curl_msnprintf(buf, sizeof(buf), "%*f", INT_MIN, 9.1);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ```
  Ref: https://app.circleci.com/pipelines/github/curl/curl/10226/workflows/87642ee9-cda6-4916-8206-c82aac5f595e/jobs/107669?invite=true#step-106-40996_46

  The root cause of why this option gets enabled remains undiscovered.

  Reported-by: Daniel Stenberg
  Fixes #15008
  Follow-up to 71cf0d1fca #14772

- build: drop `-Wno-format-overflow` from picky warning list.
  These options only get used with picky warnings enabled.
  Follow-up to 145f87b9e8 #14598

- unit1652: suppress in source (and not rely on picky warnings anymore.)

Closes #15012
2024-09-23 11:52:55 +02:00
Viktor Szakats
6a1dcdc5d2
cmake: tidy up
- unroll two short loops.
- unfold lines.
- merge lines with their comments.
- add missing quotes.
- tidy up grammar in error/warning messages.

Cherry-picked from #14692
Closes #14998
2024-09-22 09:51:15 +02:00
Viktor Szakats
e1ab01d1bd
cmake: expand CURL_USE_PKGCONFIG to non-cross MINGW
Enable `CURL_USE_PKGCONFIG` by default for more environments:

- for `MINGW` targets when not using cross-compilation.
- stop restricting vcpkg to MSVC. (this currently unlocks mingw,
  also unlocked by the update above.)

Also:
- cache `CURL_USE_PKGCONFIG` in `CURLConfig.cmake`.
  Suggested-by: Kai Pastor

Follow-up to c555ab469d #14575
Closes #14658
2024-09-21 00:59:51 +02:00
Viktor Szakats
8498b1b953
cmake/FindNGTCP2: use library path as hint for finding the crypto module
It allows finding the ngtcp2 crypto interface library automatically when
using a custom `NGTCP2_LIBRARY`.

Before this patch the library location had to be added via
`CMAKE_LIBRARY_PATH` or by other means.

Also add empty lines for readability / uniformity.

Fixes 8b8909e120/curl.sh (L289)
Closes #14905
2024-09-19 15:56:30 +02:00
Viktor Szakats
abf737b3ce
cmake: drop redundant zlib var, rename function (internals)
- drop redundant internal variable `USE_ZLIB`, rely on `HAVE_LIBZ`.

- rename `optional_dependency()` -> `curl_dependency_option()`
  Make `grep 'option('` hit this option. Namespaced.
  It has a single use with `ZLIB`.

Closes #14918
2024-09-19 12:56:22 +02:00
Viktor Szakats
04e3621dce
build: add poll() detection for cross-builds
For cross-builds rely on `_POSIX_C_SOURCE` to decide if `poll()` is
supported, rather than just assuming it isn't.

This may still miss to detect `poll()` support, as seen for example with
Linux MUSL cross-builds.

Also:

- GHA/curl-for-win: enable RISC-V 64 cross-target for Linux MUSL.
  (to test this case with cmake, with a false-negative.)
  The first RISC-V 64 build in curl's CI.

- GHA/curl-for-win: add arm64/intel64 job for Linux glibc.
  (to test this case with cmake, and succeed.)

- cmake: delete unnecessary `#include <sys/time.h>` from non-cross-build
  `poll()` detection snippet.
  Follow-up tp cc8b813765 #14718

Fixes #14714
Closes #14734
2024-08-30 17:14:33 +02:00
Viktor Szakats
cc8b813765
build: drop unused feature-detection code for Apple poll()
Drop Apple-specific detection logic for `poll()`. This detection snippet
has been disabled for Apple in both configure and cmake, for `poll()`
being broken on Apple since 10.12 Sierra (2016).

Also replace `exit(1);` with `return 1;` in configure, to make the
snippets match.

Added in 9297ca49f5 #1057 (2016-10-11).

Disabled for:
configure/darwin in a34c7ce754 (2016-10-18)
cmake/macOS in 825911be58 #7619
cmake/iOS in d14831233d #8244
cmake/all Apple in a86254b393 #12515

Closes #14718
2024-08-29 17:54:53 +02:00
Viktor Szakats
aaacd02466
GHA/configure-vs-cmake: add Windows build, fix issues
- configure: disable pthreads by default on Windows.
- configure: disable detecting `fseeko()` on Windows.
  (It exists in mingw-w64 2.0.0 and newer, but it's permanently ignored
  in CMake, as this function is never necessary on Windows.)
- extend existing exceptions with their Windows variants.
- `lib/formdata.c`: prioritize `_fseeki64()` over `fseeko()`.
  To reduce the difference between Windows builds, which now all use
  `_fseeki64()`.
- cmake: perm-enable `HAVE_DIRENT_H` and `HAVE_OPENDIR` for mingw-w64,
  to match configure.
  Follow-up to bfe54b0e88 #13137
  This in theory could make the dir listing feature work in mingw-w64
  build, but in my tests (on WINE) it failed at the preceding `open()`
  call.
- cmake: perm-enable `HAVE_STRINGS_H` and `HAVE_UTIME_H` for mingw-w64,
  to match configure. (They are wrappers and make no difference in the build.)

Also:
- configure: sync `USE_MANUAL` macro with cmake, by only setting it for
  `src`. Drop checker exception.
- CI: use `--disable-dependency-tracking` in existing jobs.
- CI: install packages before git checkout, in existing jobs.

Closes #14678
2024-08-26 11:07:58 +02:00
Viktor Szakats
8b09138083
cmake: minor tidy-ups
- show `OpenSSL v3+` when detected (as in `./configure`).
  (this string also makes its way to `curl-config`.)
- prefer `unset(VAR)` over `set(VAR)`.
  Same effect, but `unset()` tells the intent unambiguously.
  https://cmake.org/cmake/help/latest/command/set.html
- drop "implementation" from an `option()` description.
- FindGSS: replace legacy keyword alias with modern alternative.
  https://cmake.org/cmake/help/latest/command/get_filename_component.html
- move `CURL_STATIC_CRT` logic next to its `option()`.
- improve order of `libcurl.pc`/`curl-config` variable init lines.
- tests: drop/shorten custom target names.
  They inflated generated make files by 550KB.
  Keep target name logic for sync between code snippets.
  Follow-up to a2ef5d36b3 #14660
- clear a variable after use.
- restore `STATUS` for `Features:`/`Protocols:` `message()`s:
  Without it the output goes to stderr, and appears in red in CMake GUI.
  It doesn't seem possible to show a line on stdout without leading
  underscores to match `curl -V` and `./configure` output.
  Partial revert of acbc6b703f #14197
- WindowsCache: move `HAVE_LINUX_TCP_H` into the header group.
- move strings to the same line as their `STRING` keyword.
- formatting in generated code.
- delete bogus comment.
- unfold lines for readability.
- fix a too long line. (for cmakelint)
- missing quotes, whitespace, comments.

Closes #14610
2024-08-26 11:00:08 +02:00
Viktor Szakats
7c0b6eb3bd
cmake: respect cflags/libdirs of native pkg-config detections
In Find modules with native pkg-config detection (libgsasl, libidn2,
libssh, libuv, nettle) use the C compiler flags returned by pkg-config.
Also use the library paths, and return the pathless library names.

Also:
- add these library paths to `libcurl.pc`/`curl-config`.
- fix libgsasl detection to use the detected header directory.

FindGSS already did this before this patch.

Fixes #14641

Closes #14652
2024-08-23 10:43:43 +02:00
Viktor Szakats
4f09967a3c
cmake/FindGSS: bring closer to other Find modules
- add pkg-config-specific 'Found' message to the Find module.

- update non-pkg-config 'Found' message to show the flavour instead of
  the library name. (= the first value listed after `REQUIRED_VARS`)

- delete extra 'Found' message from `CMakeLists.txt`.

- rename internal result variables to match with default pkg-config
  names, in preparation of introducing them in other Find modules:
  - `GSS_LINK_DIRECTORIES` -> `GSS_LIBRARY_DIRS`
  - `GSS_LINKER_FLAGS` -> `GSS_LDFLAGS`
  - `GSS_COMPILER_FLAGS` -> `GSS_CFLAGS`

  Ref: #14652

Closes #14651
2024-08-23 10:43:43 +02:00
Viktor Szakats
0c37894611
cmake: pkg-config 'found' message sync with native CMake
Cherry-picked from #14610
2024-08-23 00:11:23 +02:00
Viktor Szakats
b3e1fe6dd6
cmake: tidy up option descriptions
- capitalize.
- impartive voice.
- stick to `Build ...`, `Use ...`, `Enable ...`, `Disable ...` with
  a couple of exceptions.
- drop period.
- fix wolfSSH, WebSockets casing.

Closes #14636
2024-08-21 23:36:12 +02:00
Viktor Szakats
3065f106e3
build: add iphlpapi lib for libssh on Windows
vcpkg doesn't need it because it fixes this with a libssh patch.
All other Windows builds need it.

(autotools build not tested.)

Closes #14618
2024-08-21 10:07:13 +02:00
Viktor Szakats
422696f0a4
cmake: migrate dependency detections to Find modules
For: libgsasl, libidn2, libssh, libuv.

The new Find modules retain using `pkg-config` natively, not as a "hint"
for the CMake-native detection. Of the pre-existing Find modules, only
FindNettle, and FindGSS (with customized code) work this way. Align
detection code for the new modules and add version detection for the
CMake-native paths.

Also, add CMake-native detection for `libgsasl`.

The remaining outlier in `CMakeLists.txt` is GnuTLS, which has
a CMake built-in Find module, but which lacks `pkg-config` support,
required for vcpkg. It remains unchanged.

Another part-outlier is `libssh`, which keeps requiring the trick
`find_package(libssh CONFIG QUIET)` for reasons I could not yet figure
out.

Closes #14555
2024-08-20 11:38:40 +02:00
Viktor Szakats
c555ab469d
cmake: limit pkg-config to UNIX and MSVC+vcpkg by default
Limits `pkg-config` to UNIX and MSVC with vcpkg, by default. Compared to
curl 8.9.1, this unlocks `pkg-config` on MSVC with vcpkg.

This condition might be updated in the future depending on where
`pkg-config` can be useful without breaking things. (e.g. to non-cross
MINGW, or all MINGW).

In the meantime everyone is free to override the default and test their
build with `pkg-config` by setting the `CURL_USE_PKGCONFIG=ON` CMake
option.

Closes #14575
2024-08-20 00:50:11 +02:00
Viktor Szakats
211cbcb4f6
cmake: rename Find modules
- `FindCARES`   -> `FindCares`
- `FindLibPSL`  -> `FindLibpsl`
- `FindLibSSH2` -> `FindLibssh2`
- `FindQUICHE`  -> `FindQuiche`
- `Findrustls`  -> `FindRustls`

Our convention for naming Find modules (the part after the `Find`
prefix, also called as 'package name') is:

Always start with uppercase. Follow with lowercase, unless there is
a clear preference for a stylized name. E.g. the project itself uses it
that way with a matching `<Name>Config.cmake` file, or we use it that
way elsewhere, or the name is an acronym.

Ref: #14580

Closes #14601
2024-08-20 00:50:10 +02:00
Viktor Szakats
3a2e47afb7
cmake: fix Find module and package names
- fix BearSSL warning about name mismatch.
- fix Nettle Find module not found on Linux.
- tidy-up: drop quotes from a package name.

Package names must match case-sensitively to work on all platforms:
- `find_package(<NAME> ...)` in `CMakeLists.txt`.
- `CMake/Find<NAME>.cmake` filenames.
- `find_package_handle_standard_args(<NAME> ...` in Find modules.
- `message(STATUS "Found <NAME> ...` in Find modules.
  (to match the message shown by `find_package_handle_standard_args()`)

Closes #14599
2024-08-20 00:44:43 +02:00
Daniel Stenberg
145f87b9e8
build: use -Wno-format-overflow
-Wformat-overflow is not a warning that we want enabled as it does not
help us. It can only bring us false positives since it warns on bad uses
of sprintf and vsprintf ("that might overflow the destination buffer").
Two functions we explicitly ban in curl code.

The only way this flag triggers warnings in curl code is false positives
for functions we have marked with the CURL_PRINTF() macro.

Further: it seems -Wformat-trunaction option might in turn also enable
-Wformat-overflow, so if this second option is used, we need to
explicitly set -Wno-format-overflow - not just skip setting
-Wformat-overflow.

Reported-by: Viktor Szakats
Fixes #14168
Closes #14598
2024-08-19 23:20:45 +02:00
Viktor Szakats
c2e814f8d7
cmake/FindNettle: log message when found via pkg-config
The message mimics the CMake-native message (by
`find_package_handle_standard_args()`), with the header path and version number.

Closes #14596
2024-08-19 14:09:14 +02:00
Viktor Szakats
47849be5d5
cmake/FindNettle: skip pkg-config for custom configs
If either `NETTLE_INCLUDE_DIR` or `NETTLE_LIBRARY` is set to customize
the `nettle` dependency, skip `pkg-config` and use the CMake-native
detection to honor these custom settings.

Closes #14584
2024-08-19 14:09:14 +02:00
Viktor Szakats
dcf5a5383c
cmake: fix cmakelint warnings
- keep line lengths below 132 characters.
- fix two "weird indentation" warnings.

Reported-by: Dan Fandrich
Bug: #14580

Closes #14583
2024-08-18 22:53:09 +02:00
Viktor Szakats
3e60f174ee
cmake: tidy up more in Find modules
- add `NAMES` where missing.
- document input variables (including deprecated ones.)
- comment cleanups.
- FindWolfSSL: drop stray `QUIET` from `pkg_check_modules()`.
  (`QUIET` may be re-added for all modules in the future.)

Closes #14579
2024-08-18 22:53:09 +02:00
Viktor Szakats
1d29246534
cmake: tidy up around ngtcp2 and wolfSSL
- fix to add the `m` library without path.
  Follow-up to 8577f4ca08 #14343
  Authored-by: Tal Regev
  Fixes #14549

- move `m` library detection to wolfSSL Find module.
  `m` is necessary for wolfSSL (wolfcrypt) library functions called by
  `libngtcp2_crypto_wolfssl`.
  Follow-up to 8577f4ca08 #14343

- fix comment header about supported `COMPONENT` names.

- quote strings.

- lowercase local variables.

Closes #14576
2024-08-18 11:17:20 +02:00
Viktor Szakats
24889acbfb
cmake: do not unset the deprecated mixed-case variables
To avoid interference with the calling env.

(Keep unsetting for the DIRS/DIR cases in BearSSL and mbedTLS, because
the deprecated variables play a new role in the detection.)

Follow-up to 9fbda4ca75 #14574
2024-08-17 22:50:16 +02:00
Viktor Szakats
9fbda4ca75
cmake: rename wolfSSL and zstd config variables to uppercase
To match with other config variables and other projects.

Rename these CMake configuration variables:
- `WolfSSL_INCLUDE_DIR` -> `WOLFSSL_INCLUDE_DIR`
- `WolfSSL_LIBRARY`     -> `WOLFSSL_LIBRARY`
- `Zstd_INCLUDE_DIR`    -> `ZSTD_INCLUDE_DIR`
- `Zstd_LIBRARY`        -> `ZSTD_LIBRARY`

The old values continue to work, with a warning suggesting the new name.

Also:
- add similar warnings for earlier renames for mbedTLS and BearSSL.
- rename internal variables `PC_Zstd_*` to uppercase.

Follow-up to db39c668a8 #14542

Closes #14574
2024-08-17 21:23:51 +02:00
Viktor Szakats
432f2fd9ac
cmake: sync up version detection in Find modules
- use the same pattern across all Find modules:
  - verify if the version header exists before reading it.
  - use a single regex per lookup.
  - sync regexes between Find modules.
  - use generic temporary variable names.
  - improve readability.
  - make it simpler to transition to new CMake syntax in the future:
    ```cmake
    file(STRINGS "${CARES_INCLUDE_DIR}/ares_version.h" _version_str REGEX "<...>")
    unset(_version_str)
    set(CARES_VERSION "${CMAKE_MATCH_1}")
    ```
    Ref: https://cmake.org/cmake/help/latest/policy/CMP0159.html#policy:CMP0159

- fix zstd version detection to be CMake 3.7 compatible.
  Required 3.9 before this patch, for the `CMAKE_MATCH_<n>` feature.
  Follow-up to c5d506e9bb #12200

Follow-up to 4e2f3641f8 #14548

Closes #14572
2024-08-17 10:33:26 +02:00
Viktor Szakats
d8de4806e1
cmake: tidy-up continues
- move variable dump to a GHA foldable group.
- minimize scope for an include().
- rename `HIDES_CURL_PRIVATE_SYMBOLS` to `CURL_HIDES_PRIVATE_SYMBOLS`,
  to keep it in the curl namespace.
- drop quotes from a version number.
- add missing `Makefile.inc` var refs to comment.
- FindNGTCP2: rename internal var to underscore/lowercase.
- FindBearSSL, FindGSS: whitespace.

Closes #14571
2024-08-17 00:32:38 +02:00
Viktor Szakats
f3a03df6a1
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
2024-08-17 00:31:52 +02:00
Viktor Szakats
4beb236478
cmake: fixup variable reference in FindZstd
Follow-up to 4e2f3641f8 #14548
2024-08-16 19:10:46 +02:00
Viktor Szakats
4e2f3641f8
cmake: add missing version detection to Find modules
- use `pkg-config` version when available and where it wasn't yet used.

- add manual version detection for dependencies where this is possible
  (via a public header) and where it wasn't done yet.

Closes #14548
2024-08-16 16:53:44 +02:00
Viktor Szakats
0d8fdd1c74
cmake: add wolfSSH support
Enable with CMake option `-DCURL_USE_WOLFSSH=ON`. Customize with
`-DWOLFSSH_INCLUDE_DIR=<path-to-wolfssh>/include`,
`-DWOLFSSH_LIBRARY=<path-to-wolfssh>/lib/libwolfssh.a`.

It requires the wolfSSL TLS backend.

Closes #14568
2024-08-16 09:36:57 +02:00
Jan Venekamp
178e8ba2d1
cmake: fix find rustls
Follow-up to 2784801977 #14545
Closes #14567
2024-08-15 23:09:09 +02:00
Viktor Szakats
2784801977
cmake: add missing pkg-config hints to Find modules
- brotli, c-ares, libpsl, libssh2, mbedtls, rustls:
  Use `pkg-config` for path hints and version info. Syncing them up with
  the rest of Find modules.

- GHA/macos: force-disable libssh2 with cmake to sync with autotools.
  After this patch, cmake auto-detects libssh2 in this job.

Closes #14545
2024-08-15 09:29:06 +02:00
Jan Venekamp
ed76a23fcc
cmake: add rustls
Closes #14534
2024-08-14 15:05:53 +02:00
Viktor Szakats
db39c668a8
cmake: sync up result variable names in Find modules
- bearssl, c-ares, gss, libpsl, libssh2, mbedtls:
  Before this patch these Find modules returned results via
  `<NAME>_INCLUDE_DIR` and `<NAME>_LIBRARY`.

  This patch makes them return `<NAME>_INCLUDE_DIRS` (note the `S`)
  and `<NAME>_LIBRARIES` like other modules already did.

- bearssl, mbedtls:
  Before this patch these Find modules allowed custom configuration
  via `<NAME>_INCLUDE_DIRS` (note the `S`).

  This patch makes them accept `<NAME>_INCLUDE_DIR`, like the rest of
  the modules did.

  Deprecate the old variables, but keep accepting them for
  compatibility.

- bearssl: add missing `mark_as_advanced()` call.

Closes #14542
2024-08-14 14:58:58 +02:00
Viktor Szakats
65f5caee05
cmake: tidy up Find modules
Smoothen out minor differences between Find modules.

- brotli, nghttp2: drop redundant `FOUND_VAR` specifiers from
  `find_package_handle_standard_args()` calls.
  This function sets both `<NAME_UPPER>_FOUND` and `<NAME>_FOUND`
  by default.

- brotli: set result vars only when found.

- brotli: add missing `mark_as_advanced()` call.

- brotli: delete custom fail message.

- mbedtls, bearssl: use `REQUIRED_VARS` instead of `DEFAULT_MSG`.

- msh3, quiche: set `<NAME>_VERSION` (via pkg-config).

- wolfssl: also use `PC_WOLFSSL_INCLUDEDIR`, `PC_WOLFSSL_LIBDIR`
  as hints.

- libpsl, libssh2, zstd: clear temporary variables used for version
  detection.

- gss, msh3, nghttp2, nghttp3, ngtcp2, quiche, zstd: fix to apply
  `mark_as_advanced()` to internal variables only.

Closes #14538
2024-08-14 12:09:33 +02:00