@@ -3,42 +3,66 @@ cmake_minimum_required(VERSION 3.5)
3
3
# Set extension name here
4
4
set (TARGET_NAME http_client)
5
5
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
9
14
find_package (OpenSSL REQUIRED)
10
15
11
16
set (EXTENSION_NAME ${TARGET_NAME} _extension)
12
17
set (LOADABLE_EXTENSION_NAME ${TARGET_NAME} _loadable_extension)
13
18
14
19
project (${TARGET_NAME} )
20
+
15
21
include_directories (src/include duckdb/third_party/httplib)
16
22
17
23
set (EXTENSION_SOURCES src/http_client_extension.cpp)
18
24
19
25
if (MINGW)
20
- set (OPENSSL_USE_STATIC_LIBS TRUE )
26
+ set (OPENSSL_USE_STATIC_LIBS TRUE )
21
27
endif ()
22
28
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
+ )
25
34
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
26
54
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES} )
27
55
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES} )
28
56
57
+ # Include directories
29
58
include_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} )
32
59
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} )
39
63
40
64
install (
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