diff --git a/CMakeLists.txt b/CMakeLists.txt index a54c2ff..3b83a7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -852,11 +852,11 @@ endif() # Check for idn2 option(USE_LIBIDN2 "Use libidn2 for IDN support" ON) if(USE_LIBIDN2) - check_library_exists("idn2" "idn2_lookup_ul" "" HAVE_LIBIDN2) - if(HAVE_LIBIDN2) - set(CURL_LIBS "idn2;${CURL_LIBS}") - check_include_file_concat("idn2.h" HAVE_IDN2_H) - endif() + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBIDN2 REQUIRED libidn2) + set(HAVE_LIBIDN2 TRUE) + list(INSERT CURL_LIBS 0 ${LIBIDN2_LINK_LIBRARIES}) + set(HAVE_IDN2_H TRUE) else() set(HAVE_LIBIDN2 OFF) endif()