From: Viktor Szakats Date: Sat, 13 Jul 2024 11:06:33 +0000 (+0200) Subject: cmake: fix builds with detected libidn2 lib but undetected header X-Git-Tag: curl-8_9_0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=764fbabf6ed4c1d36c0ab2033ac8df52d9923cd7;p=thirdparty%2Fcurl.git cmake: fix builds with detected libidn2 lib but undetected header It caused IDN to appear in `curl-config`, `libidn2` referenced from `libcurl.pc`, fail to fallback to `pkg-config` detection. But libidn2 not actually used. It came up in macOS CI builds after enabling cmake build tests. It remained hidden for a while due to setting `-DUSE_APPLE_IDN=ON`. (The half-detection of Homebrew libidn2 was the result of configuring with `-DCMAKE_EXE_LINKER_FLAGS=-L$(brew --prefix)/lib`, to fix linking GnuTLS that needs the `nettle` lib from the brew prefix.) ``` FAIL 1014: [Compare curl --version with curl-config --features] curl-config ``` Ref: https://github.com/curl/curl/actions/runs/9919357748/job/27405080722 Cherry-picked from #14097 Closes #14175 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a130c151..60279e04a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -912,7 +912,8 @@ if(USE_LIBIDN2) if(HAVE_LIBIDN2) set(LIBIDN2_LINK_LIBRARIES "idn2") check_include_file_concat("idn2.h" HAVE_IDN2_H) - else() + endif() + if(NOT HAVE_LIBIDN2 OR NOT HAVE_IDN2_H) find_package(PkgConfig QUIET) pkg_check_modules(LIBIDN2 "libidn2") if(LIBIDN2_FOUND) @@ -921,7 +922,7 @@ if(USE_LIBIDN2) set(HAVE_IDN2_H ON) endif() endif() - if(HAVE_LIBIDN2) + if(HAVE_LIBIDN2 AND HAVE_IDN2_H) set(CURL_LIBS "${LIBIDN2_LINK_LIBRARIES};${CURL_LIBS}") set(LIBCURL_PC_REQUIRES_PRIVATE "libidn2;${LIBCURL_PC_REQUIRES_PRIVATE}") endif() @@ -1727,7 +1728,9 @@ if(NOT CURL_DISABLE_INSTALL) _add_if("gsasl" USE_GSASL) _add_if("zstd" HAVE_ZSTD) _add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32) - _add_if("IDN" HAVE_LIBIDN2 OR USE_WIN32_IDN OR USE_APPLE_IDN) + _add_if("IDN" (HAVE_LIBIDN2 AND HAVE_IDN2_H) OR + USE_WIN32_IDN OR + USE_APPLE_IDN) _add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES)) _add_if("SSPI" USE_WINDOWS_SSPI)