Skip to content

Commit

Permalink
[curl] Update libssh2/brotli/c-ares dependencies (microsoft#32287)
Browse files Browse the repository at this point in the history
* [curl] Fix libssh2 dependency

* Revise dependencies patching

* Fix pc file

* Cleanup
  • Loading branch information
dg0yt authored Jul 7, 2023
1 parent 88f5e89 commit b25f6bf
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 44 deletions.
29 changes: 0 additions & 29 deletions ports/curl/0023-fix-find-cares.patch

This file was deleted.

8 changes: 1 addition & 7 deletions ports/curl/cmake-project-include.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function(vcpkg_curl_flatten input output)
list(REMOVE_AT input_libs 0)
while(input_libs)
list(POP_BACK input_libs lib)
string(REGEX REPLACE "^.<LINK_ONLY:(.*)>\$" "\\1" lib "${lib}")
if(TARGET "${lib}")
set(import_lib "")
set(import_location "")
Expand Down Expand Up @@ -69,13 +70,6 @@ function(vcpkg_curl_flatten input output)
set("${output}" "${output_libs}" PARENT_SCOPE)
endfunction()

if(CURL_USE_LIBSSH2)
find_package(Libssh2 CONFIG REQUIRED)
set(LIBSSH2_FOUND TRUE)
get_target_property(LIBSSH2_INCLUDE_DIR Libssh2::libssh2 INTERFACE_INCLUDE_DIRECTORIES)
set(LIBSSH2_LIBRARY Libssh2::libssh2)
endif()

if(USE_LIBIDN2)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBIDN2 REQUIRED libidn2)
Expand Down
60 changes: 60 additions & 0 deletions ports/curl/dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in
index dbe4ed2..267108e 100644
--- a/CMake/curl-config.cmake.in
+++ b/CMake/curl-config.cmake.in
@@ -30,6 +30,15 @@ endif()
if(@USE_ZLIB@)
find_dependency(ZLIB @ZLIB_VERSION_MAJOR@)
endif()
+if("@USE_ARES@")
+ find_dependency(c-ares CONFIG)
+endif()
+if("@USE_LIBSSH2@")
+ find_dependency(Libssh2 CONFIG)
+endif()
+if("@HAVE_BROTLI@")
+ find_dependency(unofficial-brotli CONFIG)
+endif()

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42c9ae4..8c42d91 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,7 +149,8 @@ set(CURL_LIBS "")

if(ENABLE_ARES)
set(USE_ARES 1)
- find_package(CARES REQUIRED)
+ find_package(CARES NAMES c-ares CONFIG REQUIRED)
+ set(CARES_LIBRARY c-ares::cares)
list(APPEND CURL_LIBS ${CARES_LIBRARY})
endif()

@@ -522,7 +523,9 @@ endif()
option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF)
set(HAVE_BROTLI OFF)
if(CURL_BROTLI)
- find_package(Brotli QUIET)
+ find_package(BROTLI NAMES unofficial-brotli REQUIRED)
+ set(BROTLI_INCLUDE_DIRS "")
+ set(BROTLI_LIBRARIES "unofficial::brotli::brotlidec")
if(BROTLI_FOUND)
set(HAVE_BROTLI ON)
set(CURL_LIBS "${BROTLI_LIBRARIES};${CURL_LIBS}") # For 'ld' linker. Emulate `list(PREPEND ...)` to stay compatible with <v3.15 CMake.
@@ -796,7 +800,13 @@ mark_as_advanced(CURL_USE_LIBSSH2)
set(USE_LIBSSH2 OFF)

if(CURL_USE_LIBSSH2)
- find_package(LibSSH2)
+ find_package(LIBSSH2 NAMES Libssh2 REQUIRED)
+ if(TARGET Libssh2::libssh2_shared)
+ set(LIBSSH2_LIBRARY Libssh2::libssh2_shared)
+ else()
+ set(LIBSSH2_LIBRARY Libssh2::libssh2_static)
+ endif()
+ get_target_property(LIBSSH2_INCLUDE_DIR "${LIBSSH2_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES)
if(LIBSSH2_FOUND)
list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY})
list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
2 changes: 1 addition & 1 deletion ports/curl/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vcpkg_from_github(
0022-deduplicate-libs.patch
mbedtls-ws2_32.patch
export-components.patch
0023-fix-find-cares.patch
dependencies.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down
14 changes: 8 additions & 6 deletions ports/curl/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ if(CURL_FOUND)
if(_curl_link_libraries MATCHES "OpenSSL::")
string(REGEX REPLACE "([\$]<[^;]*)?OpenSSL::(SSL|Crypto)([^;]*>)?" "${OPENSSL_LIBRARIES}" _curl_link_libraries "${_curl_link_libraries}")
endif()
if(_curl_link_libraries MATCHES "Libssh2::libssh2")
if(_curl_link_libraries MATCHES "Libssh2::libssh2_(shared|static)")
# TODO: move find_dependency(Libssh2 CONFIG) into CURL config
set(_libssh2_target "${CMAKE_MATCH_0}")
find_package(Libssh2 CONFIG QUIET)
get_target_property(_libssh2_LIBRARY_DEBUG Libssh2::libssh2 IMPORTED_IMPLIB_DEBUG)
get_target_property(_libssh2_LIBRARY_RELEASE Libssh2::libssh2 IMPORTED_IMPLIB_RELEASE)
get_target_property(_libssh2_LIBRARY_DEBUG "${_libssh2_target}" IMPORTED_IMPLIB_DEBUG)
get_target_property(_libssh2_LIBRARY_RELEASE "${_libssh2_target}" IMPORTED_IMPLIB_RELEASE)
if(NOT IMPORTED_IMPLIB_DEBUG AND NOT IMPORTED_IMPLIB_RELEASE)
get_target_property(_libssh2_LIBRARY_DEBUG Libssh2::libssh2 IMPORTED_LOCATION_DEBUG)
get_target_property(_libssh2_LIBRARY_RELEASE Libssh2::libssh2 IMPORTED_LOCATION_RELEASE)
get_target_property(_libssh2_LIBRARY_DEBUG "${_libssh2_target}" IMPORTED_LOCATION_DEBUG)
get_target_property(_libssh2_LIBRARY_RELEASE "${_libssh2_target}" IMPORTED_LOCATION_RELEASE)
endif()
select_library_configurations(_libssh2)
string(REGEX REPLACE "([\$]<[^;]*)?Libssh2::libssh2([^;]*>)?" "${_libssh2_LIBRARIES}" _curl_link_libraries "${_curl_link_libraries}")
string(REGEX REPLACE "([\$]<[^;]*)?${_libssh2_target}([^;]*>)?" "${_libssh2_LIBRARIES}" _curl_link_libraries "${_curl_link_libraries}")
unset(_libssh2_LIBRARIES)
unset(_libssh2_LIBRARY_DEBUG)
unset(_libssh2_LIBRARY_RELEASE)
unset(_libssh2_target)
endif()
if(_curl_link_libraries MATCHES "::")
message(WARNING "CURL_LIBRARIES list at least one target. This will not work for use cases where targets are not resolved.")
Expand Down
1 change: 1 addition & 0 deletions ports/curl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "curl",
"version": "8.1.2",
"port-version": 1,
"description": "A library for transferring data with URLs",
"homepage": "https://curl.se/",
"license": null,
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@
},
"curl": {
"baseline": "8.1.2",
"port-version": 0
"port-version": 1
},
"curlpp": {
"baseline": "2018-06-15",
Expand Down
5 changes: 5 additions & 0 deletions versions/c-/curl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7d8ee40552d5b1c103d52b2b28d9577cb45e2593",
"version": "8.1.2",
"port-version": 1
},
{
"git-tree": "b70ded19f70e4b198d8c3f844324c7884d3faa7d",
"version": "8.1.2",
Expand Down

0 comments on commit b25f6bf

Please sign in to comment.