@@ -3,42 +3,66 @@ cmake_minimum_required(VERSION 3.5)
33# Set extension name here
44set (TARGET_NAME http_client)
55
6- # DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
7- # used in cmake with find_package. Feel free to remove or replace with other dependencies.
8- # Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
6+ # Make ZLIB support optional with default ON for desktop platforms and OFF for WASM
7+ if (EMSCRIPTEN)
8+ option (USE_ZLIB "Enable ZLIB compression support" OFF )
9+ else ()
10+ option (USE_ZLIB "Enable ZLIB compression support" ON )
11+ endif ()
12+
13+ # Find OpenSSL before building extensions
914find_package (OpenSSL REQUIRED)
1015
1116set (EXTENSION_NAME ${TARGET_NAME} _extension)
1217set (LOADABLE_EXTENSION_NAME ${TARGET_NAME} _loadable_extension)
1318
1419project (${TARGET_NAME} )
20+
1521include_directories (src/include duckdb/third_party/httplib)
1622
1723set (EXTENSION_SOURCES src/http_client_extension.cpp)
1824
1925if (MINGW)
20- set (OPENSSL_USE_STATIC_LIBS TRUE )
26+ set (OPENSSL_USE_STATIC_LIBS TRUE )
2127endif ()
2228
23- # Find OpenSSL before building extensions
24- find_package (OpenSSL REQUIRED)
29+ # Common libraries needed for both targets
30+ set (COMMON_LIBS
31+ duckdb_mbedtls
32+ ${OPENSSL_LIBRARIES}
33+ )
2534
35+ # Handle ZLIB support
36+ if (USE_ZLIB)
37+ find_package (ZLIB)
38+ if (ZLIB_FOUND)
39+ add_compile_definitions (CPPHTTPLIB_ZLIB_SUPPORT)
40+ list (APPEND COMMON_LIBS ZLIB::ZLIB)
41+ message (STATUS "Building with ZLIB support" )
42+ else ()
43+ message (STATUS "ZLIB not found, building without ZLIB support" )
44+ endif ()
45+ endif ()
46+
47+ # Windows-specific libraries
48+ if (MINGW)
49+ set (WIN_LIBS crypt32 ws2_32 wsock32)
50+ list (APPEND COMMON_LIBS ${WIN_LIBS} )
51+ endif ()
52+
53+ # Build extensions
2654build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES} )
2755build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES} )
2856
57+ # Include directories
2958include_directories (${OPENSSL_INCLUDE_DIR} )
30- target_link_libraries (${LOADABLE_EXTENSION_NAME} duckdb_mbedtls ${OPENSSL_LIBRARIES} )
31- target_link_libraries (${EXTENSION_NAME} duckdb_mbedtls ${OPENSSL_LIBRARIES} )
3259
33- if (MINGW)
34- set (WIN_LIBS crypt32 ws2_32 wsock32)
35- find_package (ZLIB)
36- target_link_libraries (${LOADABLE_EXTENSION_NAME} ZLIB::ZLIB ${WIN_LIBS} )
37- target_link_libraries (${EXTENSION_NAME} ZLIB::ZLIB ${WIN_LIBS} )
38- endif ()
60+ # Link libraries
61+ target_link_libraries (${LOADABLE_EXTENSION_NAME} ${COMMON_LIBS} )
62+ target_link_libraries (${EXTENSION_NAME} ${COMMON_LIBS} )
3963
4064install (
41- TARGETS ${EXTENSION_NAME}
42- EXPORT "${DUCKDB_EXPORT_SET} "
43- LIBRARY DESTINATION "${INSTALL_LIB_DIR} "
44- ARCHIVE DESTINATION "${INSTALL_LIB_DIR} " )
65+ TARGETS ${EXTENSION_NAME}
66+ EXPORT "${DUCKDB_EXPORT_SET} "
67+ LIBRARY DESTINATION "${INSTALL_LIB_DIR} "
68+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR} " )
0 commit comments