curl/CMake
Viktor Szakats 98f419172b
cmake/FindLibpsl: protect against pkg-config "half-detection"
Same issue as seen before with libssh2: `libpsl`'s pkg-config module
depends on another module, but that's not found. CMake ends up reporting
`LIBPSL_FOUND=YES`, while leaving `LIBPSL_INCLUDE_DIRS` empty. Then
the build fails to find `psl.h`.

The missing dependency in this case is `icu4c`, which is "keg-only",
meaning it's not exposed in the default Homebrew header, pkg-config,
lib, etc locations. It must be added to the `PKG_CONFIG_PATH` env, as
suggested by the warnings messages of `pkgconf`.

To avoid this fallout, let's ensure that `LIBPSL_INCLUDE_DIRS` is
non-empty when detecting via `pkg-config` and fall back to the CMake
detection method otherwise.

This was an issue till Homebrew libpsl 0.21.5_1, fixed in 0.21.5_2, that
no longer depends on `icu4c`.

Example log:
```
-- Checking for module 'libpsl'
--   Found libpsl, version 0.21.5
Package icu-uc was not found in the pkg-config search path.
Perhaps you should add the directory containing `icu-uc.pc'
to the PKG_CONFIG_PATH environment variable
Package 'icu-uc', required by 'libpsl', not found
[...]
-- Found Libpsl (via pkg-config):  (found version "0.21.5")
[...]
In file included from curl/_bld/lib/CMakeFiles/libcurl_static.dir/Unity/unity_0_c.c:4:
In file included from curl/lib/altsvc.c:32:
In file included from curl/lib/urldata.h:145:
curl/lib/psl.h:28:10: fatal error: 'libpsl.h' file not found
         ^~~~~~~~~~
1 error generated.
```

Follow-up to 39c741b7b0 #15408
Closes #15827
2024-12-25 21:46:55 +01:00
..
Platforms src: add CURL_STRICMP() macro, use _stricmp() on Windows 2024-12-23 22:06:07 +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 Revert: cmake: enable CURL_USE_PKGCONFIG for cross-MINGW 2024-12-17 03:21:22 +01:00
CurlSymbolHiding.cmake Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) 2024-12-16 23:20:55 +01:00
CurlTests.c tidy-up: misc 2024-12-24 01:27:26 +01:00
FindBearSSL.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindBrotli.cmake cmake: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
FindCares.cmake cmake: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
FindGSS.cmake cmake: drop redundant opening/closing .* from MATCH expressions 2024-12-20 11:38:59 +01:00
FindLDAP.cmake cmake: replace unset(VAR) with set(VAR "") for init 2024-12-16 21:12:51 +01: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/FindLibpsl: protect against pkg-config "half-detection" 2024-12-25 21:46:55 +01:00
FindLibssh2.cmake cmake: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
FindLibssh.cmake cmake/FindLibssh: sync header comment with other modules 2024-12-22 11:47:19 +01:00
FindLibuv.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindMbedTLS.cmake cmake/FindMbedTLS: drop lib duplicates early 2024-12-14 23:43:02 +01:00
FindMSH3.cmake build: omit certain deps from libcurl.pc unless found via pkg-config 2024-11-14 22:38:47 +01:00
FindNettle.cmake cmake: clear package version after pkg-config detection 2024-10-25 15:04:35 +02:00
FindNGHTTP2.cmake cmake: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
FindNGHTTP3.cmake cmake: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
FindNGTCP2.cmake cmake: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
FindQuiche.cmake cmake: document -D and env build options 2024-10-24 23:06:40 +02:00
FindRustls.cmake build: omit certain deps from libcurl.pc unless found via pkg-config 2024-11-14 22:38:47 +01: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: add native pkg-config detection for remaining Find modules 2024-12-17 02:30:55 +01:00
Macros.cmake cmake: extend zlib's AUTO option to brotli, zstd and enable if found 2024-12-17 04:06:45 +01:00
OtherTests.cmake Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) 2024-12-16 23:20:55 +01:00
PickyWarnings.cmake build: drop -Winline picky warning 2024-12-23 22:13:23 +01:00
Utilities.cmake cmake: namespace functions and macros 2024-12-16 21:55:00 +01:00