Skip to content

Commit e212ebb

Browse files
committed
modify dependency
1 parent 3ea7c4f commit e212ebb

1 file changed

Lines changed: 34 additions & 28 deletions

File tree

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -220,42 +220,49 @@ endfunction()
220220
function(resolve_cpr_dependency)
221221
prepare_fetchcontent()
222222

223+
find_package(CURL QUIET)
224+
223225
set(CPR_BUILD_TESTS
224226
OFF
225227
CACHE BOOL "" FORCE)
226-
227228
set(CPR_BUILD_STATIC
228229
ON
229230
CACHE BOOL "" FORCE)
230-
231231
set(CPR_FORCE_USE_PIC
232232
ON
233233
CACHE BOOL "" FORCE)
234-
235-
set(CPR_USE_SYSTEM_CURL
236-
OFF
237-
CACHE BOOL "" FORCE)
238-
239234
set(CPR_USE_SYSTEM_LIB_PSL
240235
ON
241236
CACHE BOOL "" FORCE)
242237

243-
# Disable IDN support in curl to avoid linking issues
244-
set(CURL_DISABLE_LDAP
245-
ON
246-
CACHE BOOL "" FORCE)
247-
248-
set(CURL_DISABLE_LDAPS
249-
ON
250-
CACHE BOOL "" FORCE)
251-
252-
set(USE_LIBIDN2
253-
OFF
254-
CACHE BOOL "" FORCE)
255-
256-
set(USE_IDN
257-
OFF
258-
CACHE BOOL "" FORCE)
238+
if(CURL_FOUND)
239+
message(STATUS "Found system curl: ${CURL_VERSION_STRING}. Configuring cpr to use it."
240+
)
241+
set(CPR_USE_SYSTEM_CURL
242+
ON
243+
CACHE BOOL "" FORCE)
244+
list(APPEND ICEBERG_SYSTEM_DEPENDENCIES CURL::libcurl) # 将系统curl作为依赖项
245+
else()
246+
message(STATUS "System curl not found. Vendoring curl for cpr.")
247+
set(CPR_USE_SYSTEM_CURL
248+
OFF
249+
CACHE BOOL "" FORCE)
250+
set(CURL_DISABLE_INSTALL
251+
ON
252+
CACHE BOOL "" FORCE)
253+
set(CURL_DISABLE_LDAP
254+
ON
255+
CACHE BOOL "" FORCE)
256+
set(CURL_DISABLE_LDAPS
257+
ON
258+
CACHE BOOL "" FORCE)
259+
set(USE_LIBIDN2
260+
OFF
261+
CACHE BOOL "" FORCE)
262+
set(USE_IDN
263+
OFF
264+
CACHE BOOL "" FORCE)
265+
endif()
259266

260267
fetchcontent_declare(cpr
261268
${FC_DECLARE_COMMON_OPTIONS}
@@ -274,13 +281,12 @@ function(resolve_cpr_dependency)
274281
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}"
275282
LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
276283

277-
if(TARGET curl-static)
278-
message(STATUS "Found vendored target 'curl-static', installing it.")
279-
install(TARGETS curl-static
284+
if(NOT CURL_FOUND AND TARGET libcurl_static)
285+
set_target_properties(libcurl_static PROPERTIES EXPORT_NAME iceberg_libcurl_static)
286+
287+
install(TARGETS libcurl_static
280288
EXPORT iceberg_targets
281289
ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}")
282-
else()
283-
message(WARNING "Could not find vendored target 'curl-static' to install.")
284290
endif()
285291

286292
set(CPR_VENDORED TRUE)

0 commit comments

Comments
 (0)