HeartLinked commented on code in PR #236: URL: https://github.com/apache/iceberg-cpp/pull/236#discussion_r2358560067
########## cmake_modules/IcebergThirdpartyToolchain.cmake: ########## @@ -430,6 +430,196 @@ function(resolve_zlib_dependency) endfunction() +# ---------------------------------------------------------------------- +# CURL (for cpr) + +function(resolve_curl_dependency) + prepare_fetchcontent() + + set(BUILD_CURL_EXE + OFF + CACHE BOOL "" FORCE) + set(BUILD_TESTING + OFF + CACHE BOOL "" FORCE) + set(CURL_ENABLE_EXPORT_TARGET + OFF + CACHE BOOL "" FORCE) + set(BUILD_SHARED_LIBS + OFF + CACHE BOOL "" FORCE) + set(CURL_STATICLIB + ON + CACHE BOOL "" FORCE) + set(HTTP_ONLY + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_LDAP + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_LDAPS + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_RTSP + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_FTP + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_FILE + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_TELNET + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_DICT + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_TFTP + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_GOPHER + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_POP3 + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_IMAP + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_SMTP + ON + CACHE BOOL "" FORCE) + set(CURL_DISABLE_SMB + ON + CACHE BOOL "" FORCE) + set(CURL_CA_BUNDLE + "auto" + CACHE STRING "" FORCE) + set(USE_LIBIDN2 + OFF + CACHE BOOL "" FORCE) + + fetchcontent_declare(CURL + ${FC_DECLARE_COMMON_OPTIONS} + GIT_REPOSITORY https://github.com/curl/curl.git + GIT_TAG curl-8_11_0 + FIND_PACKAGE_ARGS + NAMES + CURL + CONFIG) + + fetchcontent_makeavailable(CURL) + + if(TARGET OpenSSL::SSL) + message(STATUS "Adding OpenSSL to the system dependency list.") + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES OpenSSL) + endif() + + if(curl_SOURCE_DIR) + if(NOT TARGET CURL::libcurl) + add_library(CURL::libcurl INTERFACE IMPORTED) + target_link_libraries(CURL::libcurl INTERFACE libcurl_static) + target_include_directories(CURL::libcurl INTERFACE ${curl_BINARY_DIR}/include + ${curl_SOURCE_DIR}/include) + endif() + + set(CURL_VENDORED TRUE) + set_target_properties(libcurl_static PROPERTIES OUTPUT_NAME "iceberg_vendored_curl" + POSITION_INDEPENDENT_CODE ON) + add_library(Iceberg::libcurl_static ALIAS libcurl_static) + install(TARGETS libcurl_static + EXPORT iceberg_targets + RUNTIME DESTINATION "${ICEBERG_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${ICEBERG_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${ICEBERG_INSTALL_LIBDIR}") + message(STATUS "Use vendored CURL") + + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES OpenSSL) + else() + set(CURL_VENDORED FALSE) + list(APPEND ICEBERG_SYSTEM_DEPENDENCIES CURL) + message(STATUS "Use system CURL") + endif() + + set(ICEBERG_SYSTEM_DEPENDENCIES + ${ICEBERG_SYSTEM_DEPENDENCIES} + PARENT_SCOPE) + set(CURL_VENDORED + ${CURL_VENDORED} + PARENT_SCOPE) +endfunction() + +# ---------------------------------------------------------------------- +# cpr (C++ Requests) + +function(resolve_cpr_dependency) + prepare_fetchcontent() + + set(CPR_BUILD_TESTS + OFF + CACHE BOOL "" FORCE) + set(CPR_BUILD_TESTS_SSL + OFF + CACHE BOOL "" FORCE) + set(CPR_ENABLE_SSL + ON + CACHE BOOL "" FORCE) + set(CPR_USE_SYSTEM_CURL + ON + CACHE BOOL "" FORCE) + set(CPR_CURL_NOSIGNAL + ON + CACHE BOOL "" FORCE) + + set(CURL_VERSION_STRING + "8.11.0" + CACHE STRING "" FORCE) + set(CURL_LIB + "CURL::libcurl" + CACHE STRING "" FORCE) + + fetchcontent_declare(cpr + ${FC_DECLARE_COMMON_OPTIONS} + GIT_REPOSITORY https://github.com/libcpr/cpr.git Review Comment: Thanks for the feedback. While I still believe that both methods are identical from a functional and code-consistency standpoint, I'm happy to align with the recommended best practice. I've already updated the code. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org