vcpkg/ports/curl/0023-fix-find-cares.patch
Paweł Wegner 9cf4835a54
curl: fix consuming curl via find_package. (#29741)
The commit [1] broke consuming curl for downstream projects:

CMake Error at cmake-build-debug/vcpkg_installed/x64-windows-static/share/curl/CURLTargets.cmake:61 (set_target_properties):
  The link interface of target "CURL::libcurl" contains:

    c-ares::cares

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

[1]: c9eb3bd14e
2023-03-01 10:58:55 -08:00

30 lines
821 B
Diff

diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in
index 496a92d0e..564415ef6 100644
--- a/CMake/curl-config.cmake.in
+++ b/CMake/curl-config.cmake.in
@@ -30,6 +30,9 @@ endif()
if(@USE_ZLIB@)
find_dependency(ZLIB @ZLIB_VERSION_MAJOR@)
endif()
+if(@USE_ARES@)
+ find_dependency(c-ares)
+endif()
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b43520751..dbf62751f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -169,8 +169,8 @@ set(CURL_LIBS "")
if(ENABLE_ARES)
set(USE_ARES 1)
- find_package(CARES REQUIRED)
- list(APPEND CURL_LIBS ${CARES_LIBRARY})
+ find_package(c-ares CONFIG REQUIRED)
+ list(APPEND CURL_LIBS c-ares::cares)
endif()
include(CurlSymbolHiding)