349 Commits

Author SHA1 Message Date
Viktor Szakats
6af7ab3b39
cmake: quotes, whitespace, use VERSION_GREATER_EQUAL
- `NOT` + `VERSION_LESS` -> `VERSION_GREATER_EQUAL`
  Available since 3.7, which is the minimum required for curl:
  https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal
- make `CMAKE_REQUIRED_*` argument quotes consistent.
- make `CMAKE_REQUIRED_*` space alignment consistent.
- drop quote from version value for consistency with other cases.
- formatting

Closes #17002
2025-04-10 01:42:59 +02:00
Andy Pan
131a2fd5aa
socketpair: support pipe2 where available
By replacing pipe with pipe2, it would save us 4 extra system calls of
setting O_NONBLOCK and O_CLOEXEC. This system call is widely supported
across UNIX-like OS's: Linux, *BSD, and SunOS derivatives - Solaris,
illumos, etc.

Ref:
https://man7.org/linux/man-pages/man2/pipe.2.html
https://man.freebsd.org/cgi/man.cgi?query=pipe
https://man.dragonflybsd.org/?command=pipe2
https://man.netbsd.org/pipe.2
https://man.openbsd.org/pipe.2
https://docs.oracle.com/cd/E88353_01/html/E37841/pipe2-2.html
https://illumos.org/man/2/pipe2
https://www.gnu.org/software/gnulib/manual/html_node/pipe2.html

Closes #16987
2025-04-07 12:35:17 +02:00
Andy Pan
3d02872be7
socket: use accept4 when available
Linux, *BSD, and Solaris support accept4 system call that enables the
caller to assign additional flags and save some extra system calls. It
can come in handy when O_NONBLOCK or/and FD_CLOEXEC is/are required on a
socket after being accepted.

Ref:
https://man7.org/linux/man-pages/man2/accept.2.html
https://man.freebsd.org/cgi/man.cgi?query=accept4
https://man.dragonflybsd.org/?command=accept&section=2
https://man.openbsd.org/accept.2
https://man.netbsd.org/accept.2
https://docs.oracle.com/cd/E88353_01/html/E37843/accept4-3c.html
https://www.gnu.org/software/gnulib/manual/html_node/accept4.html

Closes #16979
2025-04-06 13:08:33 +02:00
Viktor Szakats
01e45f81bd
cmake/FindNGTCP2: simplify multi-pkg-config detection
Use a single `pkg_check_modules` call to detect the main & crypto libs.

Follow-up to 3b501976a9adcf20218ffb96d9041806432227e4 #16479
Closes #16980
2025-04-05 23:03:14 +02:00
Peter Kokot
dd0c9feb54
cmake: replace CMAKE_COMPILER_IS_GNUCC with CMAKE_C_COMPILER_ID
Variable `CMAKE_COMPILER_IS_GNUCC` is deprecated and
`CMAKE_C_COMPILER_ID` should be used instead.

Closes #16797
2025-03-23 00:06:25 +01:00
Peter Kokot
d03429ce03
cmake: replace exec_program() with execute_process()
The `exec_program()` is deprecated as of CMake 3.0.

This also removes the `rm_out` variable as it isn't used in the output.
In `execute_process()` the `ERROR_QUIET` and `OUTPUT_QUIET` resemble
the behavior of `exec_program(OUTPUT_VARIABLE)` behavior in this case.

Closes #16779
2025-03-23 00:06:25 +01:00
Viktor Szakats
51d8213579
core: stop redefining E* macros on Windows, map EACCES, related fixes
Before this patch, standard `E*` errno codes were redefined on Windows,
onto matching winsock2 `WSA*` error codes, which have different values.
This broke uses where using the `E*` value in non-socket context, or
other places expecting a POSIX `errno`, e.g. file I/O, threads, IDN or
interfacing with dependencies.

Fix it by introducing a curl-specific `SOCKE*` set of macros that map to
`WSA*` on Windows and standard POSIX codes on other platforms. Then
verify and update the code to use `SOCKE*` or `E*` macro depending on
context.

- Add `SOCKE*` macros that map to either winsock2 or POSIX error codes.
  And use them with `SOCKERRNO` or in contexts requiring
  platform-dependent socket error codes.

  This fixes `E*` uses which were supposed be POSIX values, not `WSA*`
  socket errors, on Windows:
  - lib/curl_multibyte.c
  - lib/curl_threads.c
  - lib/idn.c
  - lib/vtls/gtls.c
  - lib/vtls/rustls.c
  - src/tool_cb_wrt.c
  - src/tool_dirhie.c

- Ban `E*` codes having a `SOCKE*` mapping, via checksrc.
  Authored-by: Daniel Stenberg

- Add exceptions for `E*` codes used in file I/O, or other contexts
  requiring POSIX error codes.

Also:
- ftp: fix missing `SOCKEACCES` mapping for Windows.
- add `SOCKENOMEM` for `Curl_getaddrinfo()` via `asyn-thread.c`.
- tests/server/sockfilt: fix to set `SOCKERRNO` in local `select()`
  override on Windows.
- lib/inet_ntop: fix to return `WSAEINVAL` on Windows, where `ENOSPC` is
  used on other platforms. To simulate Windows' built-in `inet_ntop()`,
  as tested on a Win10 machine.
  Note:
  - WINE returns `STATUS_INVALID_PARAMETER` = `0xC000000D`.
  - Microsoft documentation says it returns `WSA_INVALID_PARAMETER`
    (= `ERROR_INVALID_PARAMETER`) 87:
    https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop#return-value
- lib/inet_ntop: drop redundant `CURL_SETERRNO(ENOSPC)`.
  `inet_ntop4()` already sets it before returning `NULL`.
- replace stray `WSAEWOULDBLOCK` with `USE_WINSOCK` macro to detect
  winsock2.
- move existing `SOCKE*` mappings from `tests/server` to
  `curl_setup_once.h`.
- add missing `EINTR`, `EINVAL` constants for WinCE.

Follow-up to abf80aae384319ef9b19ffbd0d69a1fbe7421f1f #16612
Follow-up to d69425ed7d0918aceddd96048b146a9df85638ec #16615
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377

Closes #16621
2025-03-13 00:03:25 +01:00
Viktor Szakats
f4e23950c7
build: enable -Wcast-qual, fix or silence compiler warnings
The issues found fell into these categories, with the applied fixes:

- const was accidentally stripped.
  Adjust code to not cast or cast with const.

- const/volatile missing from arguments, local variables.
  Constify arguments or variables, adjust/delete casts. Small code
  changes in a few places.

- const must be stripped because an API dependency requires it.
  Strip `const` with `CURL_UNCONST()` macro to silence the warning out
  of our control. These happen at API boundaries. Sometimes they depend
  on dependency version, which this patch handles as necessary. Also
  enable const support for the zlib API, using `ZLIB_CONST`. Supported
  by zlib 1.2.5.2 and newer.

- const must be stripped because a curl API requires it.
  Strip `const` with `CURL_UNCONST()` macro to silence the warning out
  of our immediate control. For example we promise to send a non-const
  argument to a callback, though the data is const internally.

- other cases where we may avoid const stripping by code changes.
  Also silenced with `CURL_UNCONST()`.

- there are 3 places where `CURL_UNCONST()` is cast again to const.
  To silence this type of warning:
  ```
  lib/vquic/curl_osslq.c:1015:29: error: to be safe all intermediate
    pointers in cast from 'unsigned char **' to 'const unsigned char **'
    must be 'const' qualified [-Werror=cast-qual]
  lib/cf-socket.c:734:32: error: to be safe all intermediate pointers in
    cast from 'char **' to 'const char **' must be 'const' qualified
    [-Werror=cast-qual]
  ```
  There may be a better solution, but I couldn't find it.

These cases are handled in separate subcommits, but without further
markup.

If you see a `-Wcast-qual` warning in curl, we appreciate your report
about it.

Closes #16142
2025-03-10 22:30:15 +01:00
Viktor Szakats
3b501976a9
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
2025-03-07 13:48:07 +01:00
Viktor Szakats
8537a5b0bc
windows: do not use winsock2 inet_ntop()/inet_pton()
Disable these winsock2 functions on Windows to use the curl wrappers
and preserve `WSAGetLastError()` aka `SOCKERRNO` error codes.

curl sources uses `inet_pton()` and `inet_ntop()` via its own `Curl_`
prefixed wrappers. These wrappers promise to not overwrite
`WSAGetLastError()` aka `SOCKERRNO` error codes when calling them.
But, for Windows builds with these built-in winsock2 functions detected
(meaning all supported Windows versions, except Windows CE),
the wrappers were 1-to-1 mapped to the winsock2 functions, which broke
this promise.

b06c12b724/lib/inet_ntop.c (L188-L190)
b06c12b724/lib/inet_pton.c (L66-L70)

These promises are old (a1d598399146984c99baa46db148e87c75261033) and
may not be valid anymore. In this case, the callers would have to be
updated to use `SOCKERRNO` to retrieve any error, instead of using
`errno` as they do now.

https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop
https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_pton

Closes #16577
2025-03-06 20:09:25 +01:00
Viktor Szakats
64ba75ca90
cmake: fix detection pre-fills for iOS
Follow-up to 1ecf2f11136f967deff6d2c124127250d2756c48 #16585
Follow-up to e7adf3e83747c2915c671f2e560cde6f3d4a4905 #15841

Closes #16594
2025-03-06 14:01:28 +01:00
Viktor Szakats
387311012c
tidy-up: alphasort lists, indentation/whitespace, pp
- cmake/win32-cache: alphasort items.
- configure.ac: alphasort `CURL_CHECK_FUNC_*` checks.
- configure.ac: alphasort `AC_CHECK_FUNCS` checks.
- prefer `#ifdef`/`#ifndef`.
- lib/asyn-thread: drop unused value of `USE_HTTPSRR_ARES`.
- lib/formdata: drop unused header `libgen.h`.
- indentation, whitespace.

Closes #16490
2025-03-04 01:46:53 +01:00
Viktor Szakats
baa9c647d3
cmake: sync cutoff version with autotools for picky option -ftree-vrp
Sync cutoff version for `-ftree-vrp` with autotools, which enables it
for gcc 4.3+ (cmake builds enabled it for 5.0+, before this patch).

Cherry-picked from #16476
Closes #16478
2025-02-25 16:57:45 +01:00
Viktor Szakats
29978df61f
cmake: pre-fill known type sizes for Windows OSes
To save configuration time.

After this patch, for mingw-w64 and MSVC curl's CMake builds pre-fill
almost all type sizes without auto-detection. In most cases this leaves
3 type size auto-detections. Those depend on 64/32-bitness, and `time_t`
also depends on CRT and custom options. Old mingw-w64 versions require
some extra detections. We recommend v3.0 or newer to avoid them.

For Windows CE, this patch pre-fills all type sizes.

If this is causing any issue, please report it and disable pre-filling
with `-D_CURL_PREFILL=OFF` in the meantime.

Cherry-picked from #16394
Closes #16464
2025-02-25 16:57:13 +01:00
Viktor Szakats
ea07a64cf6
cmake: avoid -Wnonnull warning in HAVE_FSETXATTR_5 detection
Seen in Android 21/35 CI jobs:
```
curl/CMake/CurlTests.c:315:16: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
   315 |   fsetxattr(0, 0, 0, 0, 0);
       |                ^
 1 warning generated.
```
Ref: https://github.com/curl/curl/actions/runs/13460225795/job/37613494183#step:9:5978

Follow-up to bd9f9b085aa242a5e93be0b2da96ce498d7813c4 #16377
Closes #16427
2025-02-21 20:53:56 +01:00
Viktor Szakats
2a292c3984
build: add Windows CE / CeGCC support, with CI jobs
Make it possible to build curl for Windows CE using the CeGCC toolchain.
With both CMake and autotools, including tests and examples, also in CI.
The build configuration is the default one with Schannel enabled. No
3rd-party dependencies have been tested.

Also revive old code to make Schannel build with Windows CE, including
certificate verification.

Builds have been throughougly tested. But, I've made no functional tests
for this PR. Some parts (esp. file operations, like truncate and seek)
are stubbed out and likely broken as a result. Test servers build, but
they do not work on Windows CE. This patch substitutes `fstat()` calls
with `stat()`, which operate on filenames, not file handles. This may or
may not work and/or may not be secure.

About CeGCC: I used the latest available macOS binary build v0.59.1
r1397 from 2009, in native `mingw32ce` build mode. CeGCC is in effect
MinGW + GCC 4.4.0 + old/classic-mingw Windows headers. It targets
Windows CE v3.0 according to its `_WIN32_WCE` value. It means this PR
restores portions of old/classic-mingw support. It makes the Windows CE
codepath compatible with GCC 4.4.0. It also adds workaround for CMake,
which cannot identify and configure this toolchain out of the box.

Notes:
- CMake doesn't recognize CeGCC/mingw32ce, necessitating tricks as seen
  with Amiga and MS-DOS.
- CMake doesn't set `MINGW` for mingw32ce. Set it and `MINGW32CE`
  manually as a helper variable, in addition to `WINCE` which CMake sets
  based on `CMAKE_SYSTEM_NAME`.
- CMake fails to create an implib for `libcurl.dll`, due to not
  recognizing the platform as a Windowsy one. This patch adds the
  necessary workaround to make it work.
- headers shipping with CeGCC miss some things curl needs for Schannel
  support. Fixed by restoring and renovating code previously deleted
  old-mingw code.
- it's sometime non-trivial to figure out if a fallout is WinCE,
  mingw32ce, old-mingw, or GCC version-specific.
- WinCE is always Unicode. With exceptions: no `wmain`,
  `GetProcAddress()`.
- `_fileno()` is said to convert from `FILE *` to `void *` which is
  a Win32 file `HANDLE`. (This patch doesn't use this, but with further
  effort it probably could be.)
  https://stackoverflow.com/questions/3989545/how-do-i-get-the-file-handle-from-the-fopen-file-structure
- WinCE has no signals, current directory, stdio/CRT file handles, no
  `_get_osfhandle()`, no `errno`, no `errno.h`. Some of this stuff is
  standard C89, yet missing from this platform. Microsoft expects
  Windows CE apps to use Win32 file API and `FILE *` exclusively.
- revived CeGCC here (not tested for this PR):
  https://building.enlyze.com/posts/a-new-windows-ce-x86-compiler-in-2024/

On `UNDER_CE` vs. `_WIN32_WCE`: (This patch settled on `UNDER_CE`)

- A custom VS2008 WinCE toolchain does not set any of these.
  The compiler binaries don't contain these strings, and has no compiler
  option for targeting WinCE, hinting that a vanilla toolchain isn't
  setting any of them either.
- `UNDER_CE` is automatically defined by the CeGCC compiler.
  https://cegcc.sourceforge.net/docs/details.html
- `UNDER_CE` is similar to `_WIN32`, except it's not set automatically
  by all compilers. It's not supposed to have any value, like a version.
  (Though e.g. OpenSSL sets it to a version)
- `_WIN32_WCE` is the CE counterpart of the non-CE `_WIN32_WINNT` macro.
  That does return the targeted Windows CE version.
- `_WIN32_WCE` is not defined by compilers, and relies on a header
  setting it to a default, or the build to set it to the desired target
  version. This is also how `_WIN32_WINNT` works.
- `_WIN32_WCE` default is set by `windef.h` in CeGCC.
- `_WIN32_WCE` isn't set to a default by MSVC Windows CE headers (the
  ones I checked at least).
- CMake sets `_WIN32_WCE=<ver>`, `UNDER_CE`, `WINCE` for MSVC WinCE.
- `_WIN32_WCE` seems more popular in other projects, including CeGCC
  itself. `zlib` is a notable exception amongst curl dependencies,
  which uses `UNDER_CE`.
- Since `_WIN32_WCE` needs "certain" headers to have it defined, it's
  undefined depending on headers included beforehand.
- `curl/curl.h` re-uses `_WIN32_WCE`'s as a self-guard, relying on
  its not-(necessarily)-defined-by-default property:
  25b445e479/include/curl/curl.h (L77)

Toolchain downloads:
- Windows:
  https://downloads.sourceforge.net/cegcc/cegcc/0.59.1/cegcc_mingw32ce_cygwin1.7_r1399.tar.bz2
- macOS Intel:
  https://downloads.sourceforge.net/cegcc/cegcc/0.59.1/cegcc_mingw32ce_snowleopard_r1397.tar.bz2

Closes #15975
2025-02-21 13:56:34 +01:00
Viktor Szakats
ee3f657607
build: silence bogus -Wconversion warnings with gcc 5.1-5.4
It's fixed in gcc 5.5.0.

Example: https://godbolt.org/z/x6Th8q844

Seen in gcc 5.1.0, 5.4.0 (both 32/64-bit) with dl-mingw:
```
lib/rtsp.c: In function 'rtsp_parse_transport':
lib/rtsp.c:1025:36: error: conversion to 'unsigned char' from 'int' may alter its value [-Werror=conversion]
           rtp_channel_mask[idx] |= (unsigned char)(1 << off);
                                    ^
lib/mprintf.c: In function 'parsefmt':
lib/mprintf.c:526:31: error: conversion to 'unsigned char' from 'int' may alter its value [-Werror=conversion]
         usedinput[width/8] |= (unsigned char)(1 << (width&7));
                               ^
lib/mprintf.c:544:35: error: conversion to 'unsigned char' from 'int' may alter its value [-Werror=conversion]
         usedinput[precision/8] |= (unsigned char)(1 << (precision&7));
                                   ^
lib/mprintf.c:559:29: error: conversion to 'unsigned char' from 'int' may alter its value [-Werror=conversion]
       usedinput[param/8] |= (unsigned char)(1 << (param&7));
                             ^
lib/cfilters.c: In function 'Curl_pollset_change':
lib/cfilters.c:935:25: error: conversion to 'unsigned char' from 'int' may alter its value [-Werror=conversion]
       ps->actions[i] |= (unsigned char)add_flags;
                         ^
```
gcc 5.1.0: https://github.com/curl/curl/actions/runs/13413103492/job/37467698381#step:9:21
gcc 5.4.0: https://github.com/curl/curl/actions/runs/13413103492/job/37467694479#step:9:19

Closes #16398
2025-02-19 18:03:23 +01:00
Daniel Stenberg
676de7f580
lib: use Curl_str_* instead of strtok_r()
Helps avoid extra mallocs. Gets rid of the private strtok_r
implementation.

Closes #16360
2025-02-17 13:18:28 +01:00
Marcel Raad
db4d617c1c
build: enable -Wjump-misses-init for GCC 4.5+
This should have caught https://github.com/curl/curl/issues/16246.

Closes https://github.com/curl/curl/pull/16252
2025-02-17 08:48:36 +01:00
Viktor Szakats
1d0ca25d8b
build: drop more unused HAVE_STRTOLL
Follow-up to e5326bfb4477f54df64e2a7d0c2627f236a7130d #16350
Closes #16353
2025-02-16 22:06:03 +01:00
Viktor Szakats
ca2f49ded0
build: fix compiler warnings in feature detections
Fix or silence compiler warnings happening in feature detections
to reduce log noise. Warnings may also get promoted to errors in certain
cases, causing missed detections.

It reduces the number of warnings by 4500+ across the linux, linux-old,
macos, non-native and windows GHA workflows (~142 jobs).

Also move picky warning logic for MSVC/Borland to
`CMake/PickyWarnings.cmake. To make them listed in the picky-warnings
log output, and to also apply to feature detections to make them compile
under the same conditions as source code. The hope is to help catching
issues faster. It also improves code quality of feature tests.

Fixed/silenced:
```
warning #177: variable "dummy" was declared but never referenced
warning #177: variable "flag" was declared but never referenced
warning #177: variable "res" was declared but never referenced
warning #592: variable "s" is used before its value is set
warning #1011: missing return statement at end of non-void function "main"
warning #1786: function "SSL_CTX_set_srp_password" (declared at line 1888 of "/usr/include/openssl/ssl.h") was declared deprecated ("Since OpenSSL 3.0")
warning #1786: function "SSL_CTX_set_srp_username" (declared at line 1887 of "/usr/include/openssl/ssl.h") was declared deprecated ("Since OpenSSL 3.0")
warning #2332: a value of type "const char *" cannot be assigned to an entity of type "char *" (dropping qualifiers)
warning: 'SSL_CTX_set_srp_password' is deprecated [-Wdeprecated-declarations]
warning: 'SSL_CTX_set_srp_password' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
warning: 'SSL_CTX_set_srp_username' is deprecated [-Wdeprecated-declarations]
warning: 'SSL_CTX_set_srp_username' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
warning: 'b' is used uninitialized [-Wuninitialized]
warning: 'gethostname' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
warning: Value stored to 'i' is never read [deadcode.DeadStores]
warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: control reaches end of non-void function [-Wreturn-type]
warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
warning: excess elements in struct initializer
warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: macro "_FILE_OFFSET_BITS" is not used [-Wunused-macros]
warning: macro "_REENTRANT" is not used [-Wunused-macros]
warning: missing braces around initializer [-Wmissing-braces]
warning: no previous extern declaration for non-static variable 'off_t_is_large' [-Wmissing-variable-declarations]
warning: no previous prototype for 'check' [-Wmissing-prototypes]
warning: no previous prototype for function 'check' [-Wmissing-prototypes]
warning: null argument where non-null required (argument 2) [-Wnonnull]
warning: passing 'const char[1]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
warning: passing argument 2 of 'SSL_CTX_set_srp_password' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: passing argument 2 of 'SSL_CTX_set_srp_username' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
warning: unused parameter 'c' [-Wunused-parameter]
warning: unused parameter 'f' [-Wunused-parameter]
warning: unused variable 'data' [-Wunused-variable]
warning: unused variable 'dummy' [-Wunused-variable]
warning: unused variable 'flag' [-Wunused-variable]
warning: unused variable 'res' [-Wunused-variable]
warning: unused variable 's' [-Wunused-variable]
warning: variable 's' set but not used [-Wunused-but-set-variable]
warning: variable 'ts' set but not used [-Wunused-but-set-variable]
```

Closes #16287
2025-02-16 02:39:35 +01:00
Viktor Szakats
e7adf3e837
cmake: add pre-fill for Unix, enable in GHA/macos, verify pre-fills
TL;DR: Save 10 minutes of CI time for GHA/macos jobs using pre-fills and
add pre-fill verification for Apple and Windows. Also restores Xcode job
and saves 1.5-10 minutes configuring iOS jobs.

Pre-filling feature detection results can bring down the CMake configure
step to ~5 seconds on most GHA runners, ~10 seconds in slow envs like
Cygwin/MSYS2.

The potential savings per job are:
- 5-40 (average 19) seconds on GHA/macos (33 jobs)
- ~10 seconds on GHA for iOS GNU Makefile (1 job)
- 1.5-10 minutes on GHA for iOS Xcode generator (1 job)
- 10 seconds on GHA/linux with native Ubuntu (12 jobs)
- 40 seconds for Cygwin/MSYS2 (2 jobs)
- 5-10 seconds for virtualized BSDs, native CPU (3 jobs)
- ~60 seconds for virtualized BSDs, emulated CPU (1 job)

On native Windows pre-filling has been in place for a long time and
saving 8 minutes (VS2019-VS2015) to 1.5-2 minutes (VS2022), 3 minutes
(VS2022 UWP), and 30-60 seconds (MinGW), per CI job.

The downside is that detection results need to be manually collected and
filtered to those that universally apply to all platforms that they are
enabled on. Another downside is that by using a cache, we're not running
the actual detections, and thus won't catch regressions in them. It
means we must make sure that the cache is solid and matches with actual
detections results. An upside is that it gives a rough overview of which
features are available on which platforms. Another upside is pre-filled
values do work for feature detections skipped for cross-builds, e.g.
`HAVE_WRITABLE_ARGV`.

This PR adds a pre-fill cache that supports all Unixes (except OmniOS)
used in CI, and makes it usable with an internal option. It also enables
it for GHA/macos CI jobs, where the maximum savings are. And also for
the two iOS [1] and two Cygwin/MSYS2 jobs. The latters don't have
pre-fill checks and we can drop them if they turn into a hassle.

Saving:
- 10 minutes of CI time per GHA/macos workflow run. [2]
- ~80 seconds per GHA/windows workflow run with Cygwin/MSYS2.
  (offsetting the cost of pre-fill verifications)
- 1.5-10 minutes per GHA/non-native runs with iOS jobs. [3]

You can enable pre-fill locally with `-D_CURL_PREFILL=ON`. It's
experimental, and if you experience a problem, file a PR or an Issue.

This PR also adds a pre-fill checker for macOS and MinGW/MSVC Windows
GHA jobs to catch if the cache diverges from real detections. It also
adds this logic to AppVeyor, but doesn't enable it due to the perf
penalty of 2 minutes mininum.

The pre-fill checker works by configuring out-of-tree with and without
pre-fill, then diffing their `lib/curl_config.h` outputs.

Exceptions are 3 detection results exposed indirectly [4], and missing
to expose 2, of which one is the C89 header `stddef.h`. While we assume
the C99 `stdint.h` available outside iOS. We can expose them in the
future, if necessary.

The pre-fill checks cost in total:
- ~20 seconds for macOS
- ~40 seconds for MinGW on GHA
- ~80 seconds for MSVC on GHA (UWP would be 2x this)

An extra time saving potential is caching type sizes. They are
well-known, and seldom change, esp. in CI. GHA/Windows jobs spend 8-17
seconds per job on these ~12 feature checks. ~5s on Cygwin/MSYS2. Couple
of seconds on other platforms. (This PR doesn't make this optimization.)

Another opportunity is doing the same for autotools, which typically
spends more time in the configuration step than cmake.

[1] Xcode job restored as a
follow-up to be5f20202c1618788b3d8f6d255543638f48bd65 #16302

[2] GHA/macos cmake configure times in seconds:
Job                                              |  Bef. | After |  Gain
:----------------------------------------------- | ----: | ----: | ----:
CM clang GnuTLS !ldap krb5                       |  21.2 |   4.5 |  16.7
CM clang LibreSSL !ldap heimdal c-ares +examples |  13.3 |   3.9 |   9.4
CM clang OpenSSL +static libssh +examples        |  20.0 |   4.6 |  15.4
CM clang OpenSSL IDN clang-tidy~ (w/chkprefill)  |  15.7 |  18.6 |  -2.9
CM clang OpenSSL gsasl rtmp AppleIDN             |  25.0 |   4.7 |  20.3
CM clang OpenSSL torture !FTP                    |  15.3 |   4.5 |  10.8
CM clang OpenSSL torture FTP                     |  25.0 |   5.9 |  19.1
CM clang SecureTransport debug                   |  18.0 |   3.8 |  14.2
CM clang macos-13 SecureTransport                |  45.8 |  12.4 |  33.4
CM clang macos-14 SecureTransport                |  15.8 |   4.6 |  11.2
CM clang macos-15 SecureTransport                |  26.8 |   6.1 |  20.7
CM clang mbedTLS openldap brotli zstd            |  15.1 |   6.5 |   8.6
CM clang wolfSSL !ldap brotli zstd               |  27.0 |   4.4 |  22.6
CM gcc-12 GnuTLS !ldap krb5                      |  39.1 |   8.7 |  30.4
CM gcc-12 LibreSSL !ldap heimdal c-ares +examples|  23.8 |   7.2 |  16.6
CM gcc-12 OpenSSL +static libssh +examples       |  20.7 |   8.5 |  12.2
CM gcc-12 OpenSSL gsasl rtmp AppleIDN            |  23.1 |  10.1 |  13.0
CM gcc-12 SecureTransport debug                  |  21.1 |   4.8 |  16.3
CM gcc-12 mbedTLS openldap brotli zstd           |  21.4 |   5.8 |  15.6
CM gcc-12 wolfSSL !ldap brotli zstd              |  21.1 |   6.9 |  14.2
CM gcc-14 macos-13 SecureTransport               |  61.9 |  18.7 |  43.2
CM gcc-14 macos-14 SecureTransport               |  30.5 |   6.4 |  24.1
CM gcc-14 macos-15 SecureTransport               |  32.7 |   8.4 |  24.3
CM llvm@15 GnuTLS !ldap krb5                     |  21.1 |   7.5 |  13.6
CM llvm@15 LibreSSL !ldap heimdal c-ares +exampl~|  24.6 |   6.8 |  17.8
CM llvm@15 OpenSSL +static libssh +examples      |  19.0 |   6.4 |  12.6
CM llvm@15 OpenSSL gsasl rtmp AppleIDN           |  19.0 |   8.2 |  10.8
CM llvm@15 SecureTransport debug                 |  18.0 |   5.4 |  12.6
CM llvm@15 macos-13 SecureTransport              |  66.2 |  25.7 |  40.5
CM llvm@15 macos-14 SecureTransport              |  31.9 |   6.1 |  25.8
CM llvm@15 mbedTLS openldap brotli zstd          |  19.5 |   8.9 |  10.6
CM llvm@15 wolfSSL !ldap brotli zstd             |  24.3 |   5.9 |  18.4
CM llvm@18 macos-15 SecureTransport              |  33.8 |   6.4 |  27.4
Total                                            | 856.8 | 257.3 | 599.5
Before: https://github.com/curl/curl/actions/runs/13311042735/job/37173478424
After: https://github.com/curl/curl/actions/runs/13313927119/job/37183206426?pr=15841

[3] iOS:
Before: https://github.com/curl/curl/actions/runs/13326401704?pr=15841
After: https://github.com/curl/curl/actions/runs/13332177764?pr=15841

[4] detection results exposed indirectly in `curl_config.h`:
- `HAVE_FILE_OFFSET_BITS` via `_FILE_OFFSET_BITS`
- `HAVE_GETHOSTBYNAME_R_*_REENTRANT` via `NEED_REENTRANT`
- `HAVE_SOCKADDR_IN6_SIN6_ADDR` via `USE_IPV6`

Closes #15841
2025-02-16 01:59:59 +01:00
Viktor Szakats
784a8ec2c1
tidy-up: delete, comment or scope C macros reported unused
To reduce the number `-Wunused-macro` compiler warnings:
- delete unused macros.
- comment out unused macro that are part of a set.
- move macros into the scope they are used.

This may be useful to enable by default, but there are tricky cases that
I didn't manage to fix and paused the effort. E.g. internal features
checks in `openssl.c`. There is more, once those are fixed.

Closes #16279
2025-02-14 10:37:14 +01:00
Viktor Szakats
92af12a7e0
cmake: drop HAVE_IN_ADDR_T from pre-fill too [ci skip]
Follow-up to 90b72607fa63d54dc280d20cb73f6df9ee665e02 #16318
2025-02-14 02:02:00 +01:00
Viktor Szakats
90b72607fa
tidy-up: drop unused CURL_INADDR_NONE macro and in_addr_t type
Closes #16318
2025-02-13 12:46:40 +01:00
Viktor Szakats
d550966bf8
cmake: fix HAVE_ATOMIC/HAVE_STDATOMIC pre-fill for clang-cl
`HAVE_ATOMIC` and `HAVE_STDATOMIC` is available in clang-cl builds.
Adjust the pre-filled values accordingly.

Detected by a temporary job comparing pre-filled and actual values
on AppVeyor CI:
https://ci.appveyor.com/project/curlorg/curl/builds/51506692/job/2v8qrytgdnlah348#L416

Closes #16313
2025-02-13 12:46:40 +01:00
Viktor Szakats
6ab1fa423b
cmake: fix/add missing feature detections for Windows/MS-DOS
Almost all feature detection results are pre-filled on Windows
for performance, so none of the issues fixed here affected builds.

For good measure, this patch add missing detections and fixes others
to make sure they work even when omitting the pre-fill.

It also fixes detecting IPv6 for MS-DOS.

- fix `HAVE_STRUCT_TIMEVAL` detection for MSVC.
  Follow-up to c1bc090d65b8d7d14e811dd36f5e8674be43dff3 #12495
- add `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection for Windows.
- fix `HAVE_STRDUP` detection for MSVC.
- fix `HAVE_SNPRINTF` detection for Windows.
  Regression from 8e345057761a8f796403923a96f2c8fd3edca647 #15164
- fix `HAVE_IOCTLSOCKET` detection for non-UWP MSVC.
- exclude `if_nametoindex` detection for Windows.
  Although it exists on Windows, detection, usage and availability is
  complicated, and curl doesn't use it on this platform.
  Regression from 8e345057761a8f796403923a96f2c8fd3edca647 #15164
- move IPv6 detections so that pre-filling and MS-DOS Watt-32
  configuration applies to them. This fixes
  `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` detection with MS-DOS.
  Ref: https://github.com/curl/curl/actions/runs/13260511764/job/37015877585#step:7:306
  Follow-up to a3585c9576abccddbd27200058912cef900c3c0f #15543

Also:
- add debug option to test without pre-filling.
- replace `NOT LESS` with `GREATER_EQUAL`

Closes #16278
2025-02-11 14:15:40 +01:00
Viktor Szakats
f1d1c98b7f
cmake: fix HAVE_GETHOSTBYNAME_R_* detections with CURL_WERROR=ON
Fix `HAVE_GETHOSTBYNAME_R_*` feature detections always failing with
`CURL_WERROR=ON` due to stripping a const.

Also fix the GHA/cmake-vs-configure to enable `CURL_WERROR=ON` to sync
this setting with `./configure` which enables it by default. With that,
CI detects this issue.

```
CMake/CurlTests.c:73:19: error: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   73 |   char *address = "example.com";
      |                   ^~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/13225827821/job/36916564107#step:33:4198

Closes #16282
2025-02-10 12:54:11 +01:00
Viktor Szakats
fb70812437
cmake: add integration tests, run them in CI
Add CMake test project consuming curl via these methods:
`FetchContent`, `add_subdirectory()`, `find_package()`.

Also:
- GHA/distcheck: run these tests in CI.
- cmakelint: exclude a warning for calling "wonky-cased" built-in
  CMake functions, such as `FetchContent_Declare()`.

Closes #16126
2025-02-07 00:15:48 +01:00
Viktor Szakats
2b9b3ec579
cmake/Find: set <Modulename>_FOUND for compatibility when found via pkg-config
For Find modules where `<Modulename>` is not fully uppercase.

`<Modulename>` is case-exact name used in the Find modules filename:
`CMake/Find<Moduleame>.cmake`.

`find_package_handle_standard_args()` sets both `<MODULENAME>_FOUND` and
`<Modulename>_FOUND` when detecting the dependency. Some CMake code
relies on this and 3rd-party code may rely on it too. Make sure to set
the latter variant when detecting the dependency via `pkg-config`, where
we don't call `find_package_handle_standard_args()`.

CMake sets these variable to `TRUE` (not `ON` or `1`). Replicate this
for compatibility.

Closes #16153
2025-02-07 00:07:38 +01:00
Viktor Szakats
aa3e4c1db5
cmake: initialize variables where missing
As detected using `cmake --warn-uninitialized`.

It also lists:
- variables inherited from `Makefile.inc`, which this PR does not fix.

- a documented CMake global variable, which is unexpected:
  `CMAKE_MODULE_PATH`.
  I'd expect CMake to initialize its namespace.

- envs: `CI`, `CURL_CI` and `CURL_BUILDINFO`. Unexpected, as the manual
  mentions variables only. As of August 2024, there is no solution to
  silence them:
  https://discourse.cmake.org/t/how-to-test-for-set-env-variables-without-getting-warnings/11401

https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-warn-uninitialized

Closes #16198
2025-02-06 23:32:37 +01:00
Viktor Szakats
3c128966ed
cmake: tidy up string append and list prepend syntax
- `set(VAR "${VAR}<value>")` ->
  `string(APPEND VAR "<value>")`
  Available since CMake 3.4:
  https://cmake.org/cmake/help/latest/command/string.html#append

- `set(VAR "${VAR2}-or-<value>;${VAR}")` ->
  `set(VAR "${VAR2}-or-<value>" ${VAR})`

Closes #16144
2025-02-06 23:25:40 +01:00
Viktor Szakats
2ed232a4e6
build: drop macro used to enable -Wsign-conversion warnings in CI
We don't pursue this, and the necessary `#pragma` got in the way of
compiling curl with gcc 4.2 and older. Drop the logic completely.

Follow-up to 8a266ac4883958c339fe16796081a296cd66acb3 #15939

Reported-by: prpr19xx on Github
Fixes #16152
Closes #16157
2025-02-03 22:28:08 +01:00
Viktor Szakats
5c31c2e670
tidy-up: .gitignore lines mostly
- `.gitignore`: delete, dedupe and move rules upwards.
  Ref: 6389ba87b8e5cf74b70c54beab3498dfc773364e #13311
- `.gitignore`: fix generated test sources.
  Follow-up to 71cf0d1fca9e1f53524e1545ef0c08d174458d80 #14772
- `.gitignore`: replace exe listings with a wildcard.
- lib: move `setup-*.h` from `EXTRA_DIST` to `CURL_HFILES`.
- `makedebug.bat`: uppercase an argument to match docs.
- GHA/non-native: delete stray env.
  Follow-up to 12a6de2f660dd692cce93cb65ce6e3ec126bb531 #16043
- sort source lists.

Closes #16093
2025-01-27 20:59:46 +01:00
Viktor Szakats
3e552ef833
cmake/Find: add iphlpapi for c-ares, omit syslibs if dep not found
- add `iphlpapi` library for c-ares.
  Ref: 082d98ba6b

- fix to not add system libs if the dependency was not found.
  librtmp, Rustls, wolfSSL
  Follow-up to 421e592db25cbbe4baadfeef8e6ed75a57579d0a #15832
  Follow-up to 7bab201abe3915a0167c002f9308950cb8a06e4b #15193

Closes #16089
2025-01-26 01:52:47 +01:00
Viktor Szakats
1bc83abfb7
cmake: drop CURL_USE_PKGCONFIG from curl-config.cmake.in
This variable was meant to be used by curl Find modules, but it turns
out it makes no sense to use those from `curl-config.cmake.in`. It means
this variable was not used before and will not be used in the future,
and therefore safe to delete.

Also add missing macros passed to `curl-config.cmake` to comment.

Ref: https://github.com/curl/curl/pull/14930#discussion_r1929537797

Closes #16087
2025-01-25 15:21:17 +01:00
Viktor Szakats
7e814c8717
build: fix compiling with GCC 4.x versions
- silence false positive picky warnings.
- avoid "possible noreturn" warnings for standalone tests and examples.
- fix to compile without `#pragma GCC diagnostic push` support.
- fix "#pragma GCC diagnostic not allowed inside functions".

Prerequisite for #15975 that needs GCC 4.4 for the latest pre-built
CeGCC/mingw32ce toolchain for Windows CE.

Cherry-picked from #15975
Closes #16062
2025-01-22 11:26:15 +01:00
Viktor Szakats
8dfd271c35
cmake: prefer dash-style MSVC options
They play better with Unixy shells. The compiler has been supporting
dash options since its early versions.

Also fix to detect warnings options passed in dash-style.

Closes #16063
2025-01-22 11:21:42 +01:00
Viktor Szakats
12a6de2f66
GHA: add iOS jobs with LibreSSL, enable dependencies for Android via vcpkg
iOS:

- add jobs with autotools, CMake, CMake Xcode generator.
  The Xcode generator is >10x slower than Unix Makefiles. Keep it
  because it's the one recommended by CMake and for having its own
  quirks we may want to know about.
- build, cache and use LibreSSL for these jobs.
  With workaround for an iOS build issue fixed in master.
- make Xcode generator work by explicitly disabling code signing.
- make tests and examples build with the Xcode generator by setting
  `-DMACOSX_BUNDLE_GUI_IDENTIFIER=se.curl`, to avoid
  "Bundle identifier is missing" errors.
- cmake: disable `CURL_USE_PKGCONFIG` by default for Apple device.
- cmake: add `stdc++` library for BoringSSL and AWS-LC, with
  `OPENSSL_USE_STATIC_LIBS=ON` set.
- cmake: add workaround for Xcode generator issue, where it cannot
  handle two targets depending on one custom command. A better fix may
  be dropping `tool_hugehelp.c` and `tool_ca_embed.c` from curltool
  library. For a future PR.

Android:

- add vcpkg to Android jobs, enable dependencies.
  Assisted-by: Tal Regev via #16045
- make vcpkg work with autotools.
- pass `--with-brotli` to autotools to detect the vcpkg-supplied brotli.
- enable BoringSSL for Android and add a job with it.
- silence 457 CMake configure warnings about the Android NDK CMake
  scripts targeting freshly deprecated CMake versions.

These were much more involved than imagined. Basically nothing works out
of the box, and when combined, everything becomes a unique edge case.
autotools builds were a much easier to make work than CMake ones.

Also:

- GHA/non-native: re-sync names to be shorter and more aligned with
  other workflows.
- GHA: add `persist-credentials: false` where missing.

Unresolved issues:

- `OPENSSL_ROOT_DIR` ignored/mis-used when pointing it to LibreSSL.
  CMake seems to prepend the sysroot to the passed absolute directory.
  Found no workaround.
- CMake when combined with Android, both the Google-recommended method
  and the built-in CMake method fail to provide a way to avoid
  `pkg-config` packages at system directories. Failed to find a knob
  that can remove `/usr/include` from the search path. The workaround is
  to disable zstd. (I enabled it by default in this release, maybe
  premature?: f2adb3b6d73cad0c28ec8a32f5fa969d0f6378a0 #15431)
  Disabling `pkg-config` doesn't work because vcpkg dependencies do not
  link without it.
- CMake's Xcode generator is slow because each `try_compile()` feature
  check springs a new CMake + Xcode project taking a long time to run,
  just to compile single-liner C files. A known issue, with no solution.
  `-DCMAKE_MACOSX_BUNDLE=OFF` did not help, limiting build types to
  a single one (e.g. `Debug`) also had no effect.
   make | Xcode | GHA run
  :---- | :---- | :--------------------------------------------------------------------
    16s | 2m57s | https://github.com/curl/curl/actions/runs/12866334102/job/35868712426
    23s | 4m13s | https://github.com/curl/curl/actions/runs/12868128013/job/35874212461
    16s | 3m39s | https://github.com/curl/curl/actions/runs/12859073531/job/35849041880
    14s | 2m23s | https://github.com/curl/curl/actions/runs/12858298423/job/35847201313
    15s | 2m36s | https://github.com/curl/curl/actions/runs/12858058492/job/35846669761
    19s | 3m19s | https://github.com/curl/curl/actions/runs/12868919430/job/35876601168

Closes #16043
2025-01-20 22:32:06 +01:00
Viktor Szakats
08e2cceaf1
cmake: drop fseeko() pre-fill and check for Windows
To sync detection code with autotools.

Closes #16041
2025-01-19 15:03:16 +01:00
Viktor Szakats
2c4bfefe91
build: stop detecting sched_yield() on Windows
On Windows a successful `sched_yield()` detection requires mingw-w64
built with POSIX threads (not Win32 threads) and GCC (not llvm/clang).
(linking to `winpthread` via custom options may also work.)

In CMake builds, it was pre-cached as unavailable before this patch.

When detected (via autotools), it got only used for Windows XP or older
targets combined with a non-GCC, non-clang compiler that doesn't support
`__builtin_ia32_pause()`, or with the Intel C compiler. According to
`lib/easy_lock.h`.

mingw-w64 only supports GCC and clang, leaving a very narrow chance when
`shed_yield()` gets called on Windows. Even then, `sched_yield()` is
implemented in `winpthread` as `Sleep(0)`, which may or not be a useful.
It's also trivial to implement locally if it is, and such rare build
combination is also deemed useful.

Thus, this patch marks `sched_yields()` permanently unavailable on the
Windows platform also with autotools, and instead of pre-caching, skip
this feature check with CMake.

This syncs `HAVE_SCHED_YIELDS` between builds methods on Windows.

Follow-up to 9b517c8b69a1f365fdb6f54f7153561182285b6c #11973
Follow-up to 23af112f5556d6a785c17e09f2422ac931405f61 #8680

Closes #16037
2025-01-17 23:31:58 +01:00
Viktor Szakats
e49797abc2
cmake: detect mingw-w64 version, pre-fill HAVE_STRTOK_R
Replace `strtok_r()` detection with detection mingw-w64 version.
The use this version to pre-fill `HAVE_STRTOK_R`.

This gives use mingw-w64 version information for free.

Closes #16022
2025-01-17 23:31:57 +01:00
Viktor Szakats
d5fb2b29d5
cmake: pre-fill HAVE_STDATOMIC_H, HAVE_ATOMIC for mingw-w64
`stdatomic.h` and `_Atomic` were first available in gcc 4.9.0 and
llvm/clang 3.6. Set detection values accordingly and save these two
detections on configure runs.

Closes #16036
2025-01-17 15:11:22 +01:00
Viktor Szakats
56a74fac47
android: add CI jobs, buildinfo, cmake docs, disable CURL_USE_PKGCONFIG by default
- GHA/non-native: add Android builds, both cmake and autotools,
  both NDK 21 (oldest available) and 35 (newest available)
  https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
  It comes with a maintenance burden to bump the oldest/latest values
  with CI runner updates.

- cmake: disable `CURL_USE_PKGCONFIG` by default for Android.
  To avoid picking up system package by default.

- build: add `ANDROID-<NDK-LEVEL>` flag to `buildinfo.txt`.
  Also detect NDK level with the CMake built-in build method:
  https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android

- INSTALL.md: add CMake build instructions for Android.

- INSTALL.md: make NDK levels consistent in `./configure` example.

Closes #16014
2025-01-17 00:44:11 +01:00
Viktor Szakats
95658f9ca3
build: fix -Wtrampolines picky warning for gcc 4.x versions
Caused an error when using cmake with gcc 4.4 and 4.5.
Also 4.3 when using autotools.

Seen with GNU 4.4.0 in CeGCC 0.59.1:
```
cc1: error: unrecognized command line option "-Wtrampolines"
```

`-Wtrampolines` requires gcc 4.6 or upper.

Ref: https://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Warning-Options.html
Ref: https://master.dl.sourceforge.net/project/cegcc/cegcc/0.59.1/cegcc_mingw32ce_snowleopard_r1397.tar.bz2

Closes #15962
2025-01-10 18:21:10 +01:00
Viktor Szakats
8a266ac488
build: delete -Wsign-conversion related FIXMEs
We decided last year not to pursue avoiding this warning, because it
adds noise and friction, while in most cases not revealing actual code
issues. We fixed the interesting portion of them throughout mid-2024.

Conclude this effort by deleting related FIXMEs and temporary comments.

Follow-up to 3829759bd042c03225ae862062560f568ba1a231 #12489
Closes #15939
2025-01-09 02:12:52 +01:00
Viktor Szakats
f6566f332f
cmake: pre-fill HAVE_STDINT_H on Windows
Closes #15925
2025-01-07 15:37:36 +01:00
Viktor Szakats
699ac9430c
cmake: publish/check supported protocols/features via CURLConfig.cmake
Via these variables, as lists:
- `CURL_SUPPORTED_PROTOCOLS`
- `CURL_SUPPORTED_FEATURES`

As individual flags:
- `CURL_SUPPORTS_<protocol/feature>` = `TRUE`

Also:
- set `CURL_VERSION_STRING` which was missing when using
  `find_package(CURL CONFIG)` or
  `find_package(CURL NO_MODULE)`.
- set `CURL_<prototol/feature>_FOUND` for compatibility.
- show full list of missing but required `COMPONENTS`.

Assisted-by: Derek Huang
Fixes #15854
Closes #15858
2025-01-04 10:29:00 +01:00
Viktor Szakats
772b6933bc
cmake/FindLDAP: avoid framework locations for libs too (Apple)
We already avoid system framework paths while looking for LDAP headers
to avoid issues.

Do the same while looking for LDAP libraries. This makes sure to find
the regular ldap library (`libldap.tbd`) instead of picking up
`ldap.framework` and let that seep into `libcurl.pc` with a full path.

This makes LDAP detection work on Apple as before introducing FindLDAP.

Follow-up to 49f2a23d509645d534cbb2e2ffbd6347fac6e59e #15273
Closes #15895
2025-01-02 12:55:50 +01:00
Viktor Szakats
27b9e76706
cmake: make system libraries dl, m, pthread customizable
via `DL_LIBRARY`, `MATH_LIBRARY`, `PTHREAD_LIBRARY` variables.

They are used in Rustls, wolfSSL Find modules.

Also:
- always use `NAMES` keyword in `find_library()` calls.
- respect `find_library()` results for `dl`, `m`, `pthread`.
- formatting.

Closes #15892
2025-01-02 12:55:50 +01:00