curl/CMake
Viktor Szakats 93e6e4b823
cmake: work around ios.toolchain.cmake breaking feature-detections
Fix builds with CMake configured to falsely return successful detection
when using `check_function_exists()` (and `check_library_exists()`, and
anything based on `try_compile()` that's relying on the linker). After
such mis-detection the build fails when trying to use the feature that
doesn't in fact exist.

The mis-detection is caused by this CMake setting:
```
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
```
It is set by default (or on conditions) when using 3rd-party toolchain:
https://github.com/leetal/ios-cmake/blob/master/ios.toolchain.cmake

After this patch the curl build overrides this setting for the duration
of feature tests, and logs a message about it.

Also preset and skip feature tests for known mis-detections:
- `connect()` in `libsocket`
- `getpass_r()`
- `eventfd()` (did not cause an issue due to a separate bug)
- `sendmmsg()` (did not cause an issue because it's Linux-only)

If mis-detections are still seen, the workaround is to force-set the
specific feature by passing `-DHAVE_*=OFF` to cmake.
Also consider passing `-DENABLE_STRICT_TRY_COMPILE=ON` for
`ios.toolchain.cmake` to fix the root cause.

Interestingly curl itself uses this setting to speed up compile-only
detections: be17f298ff #3744

Also:
- OtherTests.cmake: restore original value of
  `CMAKE_TRY_COMPILE_TARGET_TYPE`. Before this patch it reset it
  to empty.
- OtherTests.cmake: unset a local variable after use, quote a string.

Follow-up to 8e34505776 #15164
Follow-up to 8b76a8aeb2 #15525
Ref: https://github.com/leetal/ios-cmake/issues/47
Ref: https://gitlab.kitware.com/cmake/cmake/-/issues/18121
Ref: https://cmake.org/cmake/help/latest/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html
Reported-by: Dan Rosser
Fixes #15557
Closes #15559
2024-11-13 10:42:38 +01:00
..
Platforms build: use _fseeki64() on Windows, drop detections 2024-11-11 14:25:04 +01:00
cmake_uninstall.cmake.in cmake: more small tidy-ups and fixes 2024-08-08 13:48:28 +02:00
CMakeConfigurableFile.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-config.cmake.in cmake: tidy up 2024-09-22 09:51:15 +02:00
CurlSymbolHiding.cmake tidy-up: whitespace, fix CI spacecheck for docs 2024-10-30 23:15:28 +01:00
CurlTests.c cmake: apply WIN32_LEAN_AND_MEAN to all feature checks 2024-10-11 17:57:03 +02:00
FindBearSSL.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindBrotli.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindCares.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindGSS.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindLibgsasl.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindLibidn2.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindLibpsl.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindLibssh2.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindLibssh.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindLibuv.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindMbedTLS.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindMSH3.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindNettle.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindNGHTTP2.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindNGHTTP3.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindNGTCP2.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindQuiche.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindRustls.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindWolfSSH.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindWolfSSL.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindZstd.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
Macros.cmake cmake: use list(APPEND) on CURL_INCLUDES 2024-10-24 19:16:10 +02:00
OtherTests.cmake cmake: work around ios.toolchain.cmake breaking feature-detections 2024-11-13 10:42:38 +01:00
PickyWarnings.cmake build: fix clang-cl builds, add CI job 2024-10-30 23:15:32 +01:00
Utilities.cmake cmake: more syntax tidy-up 2024-08-07 23:41:27 +02:00