[oatpp-curl] Fix curl dependency cannot be found (#14385)

This commit is contained in:
NancyLi1013 2020-11-05 09:03:10 +08:00 committed by GitHub
parent 5c60f1edfe
commit 7de9efa080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 35 deletions

View File

@ -1,6 +1,6 @@
Source: oatpp-curl
Version: 1.2.0
Port-Version: 1
Port-Version: 2
Description: Oat++ Modern web framework curl module to use libcurl as a RequestExecutor on the oatpp's ApiClient
Build-Depends: curl,oatpp
Homepage: https://github.com/oatpp/oatpp-curl

View File

@ -1,33 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 477064a..5da99e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,8 +95,26 @@ message("## ${OATPP_THIS_MODULE_NAME} module. Resolving dependencies...\n")
##############################
## Find libcurl dependency
-include(FindPkgConfig)
-pkg_check_modules(PKG_CURL REQUIRED libcurl)
+if (VCPKG_TOOLCHAIN)
+ find_package(CURL REQUIRED)
+ if (CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
+ get_filename_component(PKG_CURL_LIBRARIES ${CURL_LIBRARY_DEBUG} NAME)
+ get_filename_component(PKG_CURL_LIBRARY_DIR ${CURL_LIBRARY_DEBUG} DIRECTORY)
+ else()
+ get_filename_component(PKG_CURL_LIBRARIES ${CURL_LIBRARY_RELEASE} NAME)
+ get_filename_component(PKG_CURL_LIBRARY_DIR ${CURL_LIBRARY_RELEASE} DIRECTORY)
+ endif()
+ if (PKG_CURL_LIBRARIES MATCHES [[^.*\.a$]])
+ string(LENGTH ${PKG_CURL_LIBRARIES} _LEN)
+ math(EXPR _LEN "${_LEN} - 5")
+ string(SUBSTRING ${PKG_CURL_LIBRARIES} 3 ${_LEN} PKG_CURL_LIBRARIES)
+ endif()
+ set(PKG_CURL_VERSION ${CURL_VERSION})
+ set(PKG_CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS})
+else()
+ include(FindPkgConfig)
+ pkg_check_modules(PKG_CURL REQUIRED libcurl)
+endif()
message("[libcurl] libcurl found:")
message("[libcurl] LIBRARIES=${PKG_CURL_LIBRARIES}")

View File

@ -0,0 +1,51 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 85edfe7..a8aa02b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,7 +94,7 @@ message("## ${OATPP_THIS_MODULE_NAME} module. Resolving dependencies...\n")
##############################
## Find libcurl dependency
-
+if(0)
include(FindPkgConfig)
pkg_check_modules(PKG_CURL REQUIRED libcurl)
@@ -103,9 +103,10 @@ message("[libcurl] LIBRARIES=${PKG_CURL_LIBRARIES}")
message("[libcurl] LIBRARY_DIRS=${PKG_CURL_LIBRARY_DIRS}")
message("[libcurl] INCLUDE_DIRS=${PKG_CURL_INCLUDE_DIRS}")
message("[libcurl] VERSION=${PKG_CURL_VERSION}\n")
-
+endif()
+find_package(CURL CONFIG REQUIRED)
link_directories(
- ${PKG_CURL_LIBRARY_DIRS}
+ CURL::libcurl
)
message("\n############################################################################\n")
diff --git a/cmake/module-config.cmake.in b/cmake/module-config.cmake.in
index 5cc12b0..4ff34bc 100644
--- a/cmake/module-config.cmake.in
+++ b/cmake/module-config.cmake.in
@@ -1,5 +1,6 @@
@PACKAGE_INIT@
-
+include(CMakeFindDependencyMacro)
+find_dependency(CURL)
if(NOT TARGET oatpp::@OATPP_MODULE_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@OATPP_MODULE_NAME@Targets.cmake")
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8c2087f..1da41c6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -43,7 +43,7 @@ target_include_directories(${OATPP_THIS_MODULE_NAME}
#)
target_link_libraries(${OATPP_THIS_MODULE_NAME}
- PRIVATE ${PKG_CURL_LIBRARIES}
+ PRIVATE CURL::libcurl
)
#######################################################################################################

View File

@ -8,7 +8,7 @@ vcpkg_from_github(
REF b7c0507e286fbc55ccbbb4a2604f6c46d3a86525 # 1.2.0
SHA512 274aaf34733ab70b148182332db493157ed8c87e093d09bf7dcbd9c89034dab9a97f05ba0887459a8a0ed80b2c2248c253b1ff8c933e196a6ecee11546a4488b
HEAD_REF master
PATCHES "curl-submodule-no-pkg-config-in-vcpkg.patch"
PATCHES "fix-find-curl.patch"
)
vcpkg_configure_cmake(