cmake: detect libidn2 also via pkg-config

Also:
- GHA/non-native: install `pkg-config` to detect libidn2 with cmake
  on NetBSD and FreeBSD.
- GHA/non-native: tidy-up `curl --version` command if here.

Cherry-picked from #14097
Closes #14137
This commit is contained in:
Viktor Szakats 2024-07-09 12:11:16 +02:00
parent baa3270846
commit f43adc2c49
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
2 changed files with 17 additions and 6 deletions

View File

@ -57,7 +57,7 @@ jobs:
architecture: ${{ matrix.arch }} architecture: ${{ matrix.arch }}
run: | run: |
# https://pkgsrc.se/ # https://pkgsrc.se/
sudo pkgin -y install cmake perl brotli heimdal openldap-client libssh2 libidn2 libpsl nghttp2 # python311 py311-impacket sudo pkgin -y install cmake pkg-config perl brotli heimdal openldap-client libssh2 libidn2 libpsl nghttp2 # python311 py311-impacket
cmake -B bld \ cmake -B bld \
-DCMAKE_UNITY_BUILD=ON \ -DCMAKE_UNITY_BUILD=ON \
-DCURL_WERROR=ON \ -DCURL_WERROR=ON \
@ -68,7 +68,7 @@ jobs:
-DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DCURL_USE_GSSAPI=ON \ -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON -DCURL_USE_GSSAPI=ON \
|| { cat bld/CMakeFiles/CMake*.yaml; false; } || { cat bld/CMakeFiles/CMake*.yaml; false; }
cmake --build bld --config Debug --parallel 3 cmake --build bld --config Debug --parallel 3
"$(pwd)/bld/src/curl" --disable --version bld/src/curl --disable --version
if [ '${{ matrix.arch }}' = 'x86_64' ]; then # Slow on emulated CPU if [ '${{ matrix.arch }}' = 'x86_64' ]; then # Slow on emulated CPU
cmake --build bld --config Debug --parallel 3 --target testdeps cmake --build bld --config Debug --parallel 3 --target testdeps
cmake --build bld --config Debug --target test-ci cmake --build bld --config Debug --target test-ci
@ -102,7 +102,7 @@ jobs:
-DCURL_BROTLI=ON -DUSE_NGHTTP2=ON \ -DCURL_BROTLI=ON -DUSE_NGHTTP2=ON \
|| { cat bld/CMakeFiles/CMake*.yaml; false; } || { cat bld/CMakeFiles/CMake*.yaml; false; }
cmake --build bld --config Debug --parallel 3 cmake --build bld --config Debug --parallel 3
"$(pwd)/bld/src/curl" --disable --version bld/src/curl --disable --version
if [ '${{ matrix.arch }}' = 'x86_64' ]; then # Slow on emulated CPU if [ '${{ matrix.arch }}' = 'x86_64' ]; then # Slow on emulated CPU
cmake --build bld --config Debug --parallel 3 --target testdeps cmake --build bld --config Debug --parallel 3 --target testdeps
export TFLAGS='-j8 ~3017 ~TFTP' # FIXME: TFTP requests executed twice? Related: `curl: (69) TFTP: Access Violation`? export TFLAGS='-j8 ~3017 ~TFTP' # FIXME: TFTP requests executed twice? Related: `curl: (69) TFTP: Access Violation`?
@ -156,7 +156,7 @@ jobs:
architecture: ${{ matrix.arch }} architecture: ${{ matrix.arch }}
run: | run: |
# https://ports.freebsd.org/ # https://ports.freebsd.org/
sudo pkg install -y cmake brotli openldap26-client libidn2 libnghttp2 nghttp2 stunnel py39-openssl py39-impacket py39-cryptography sudo pkg install -y cmake pkgconf brotli openldap26-client libidn2 libnghttp2 nghttp2 stunnel py39-openssl py39-impacket py39-cryptography
cmake -B bld \ cmake -B bld \
'-DCMAKE_C_COMPILER=${{ matrix.compiler }}' \ '-DCMAKE_C_COMPILER=${{ matrix.compiler }}' \
-DCMAKE_UNITY_BUILD=ON \ -DCMAKE_UNITY_BUILD=ON \

View File

@ -910,9 +910,20 @@ option(USE_LIBIDN2 "Use libidn2 for IDN support" ON)
if(USE_LIBIDN2) if(USE_LIBIDN2)
check_library_exists("idn2" "idn2_lookup_ul" "" HAVE_LIBIDN2) check_library_exists("idn2" "idn2_lookup_ul" "" HAVE_LIBIDN2)
if(HAVE_LIBIDN2) if(HAVE_LIBIDN2)
set(CURL_LIBS "idn2;${CURL_LIBS}") set(LIBIDN2_LINK_LIBRARIES "idn2")
set(LIBCURL_PC_REQUIRES_PRIVATE "libidn2;${LIBCURL_PC_REQUIRES_PRIVATE}")
check_include_file_concat("idn2.h" HAVE_IDN2_H) check_include_file_concat("idn2.h" HAVE_IDN2_H)
else()
find_package(PkgConfig QUIET)
pkg_check_modules(LIBIDN2 "libidn2")
if(LIBIDN2_FOUND)
include_directories(${LIBIDN2_INCLUDE_DIRS})
set(HAVE_LIBIDN2 ON)
set(HAVE_IDN2_H ON)
endif()
endif()
if(HAVE_LIBIDN2)
set(CURL_LIBS "${LIBIDN2_LINK_LIBRARIES};${CURL_LIBS}")
set(LIBCURL_PC_REQUIRES_PRIVATE "libidn2;${LIBCURL_PC_REQUIRES_PRIVATE}")
endif() endif()
else() else()
set(HAVE_LIBIDN2 OFF) set(HAVE_LIBIDN2 OFF)