@@ -3,12 +3,15 @@ cmake_minimum_required(VERSION 3.5)
3
3
# Set extension name here
4
4
set (TARGET_NAME http_client )
5
5
6
- # Add ZLIB definition for httplib
7
- add_compile_definitions (CPPHTTPLIB_ZLIB_SUPPORT )
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 ()
8
12
9
- # Find required packages
13
+ # Find OpenSSL before building extensions
10
14
find_package (OpenSSL REQUIRED )
11
- find_package (ZLIB REQUIRED )
12
15
13
16
set (EXTENSION_NAME ${TARGET_NAME} _extension )
14
17
set (LOADABLE_EXTENSION_NAME ${TARGET_NAME} _loadable_extension )
@@ -20,35 +23,46 @@ include_directories(src/include duckdb/third_party/httplib)
20
23
set (EXTENSION_SOURCES src/http_client_extension.cpp )
21
24
22
25
if (MINGW )
23
- set (OPENSSL_USE_STATIC_LIBS TRUE )
26
+ set (OPENSSL_USE_STATIC_LIBS TRUE )
24
27
endif ()
25
28
26
- # Build extensions
27
- build_static_extension (${TARGET_NAME} ${EXTENSION_SOURCES} )
28
- build_loadable_extension (${TARGET_NAME} " " ${EXTENSION_SOURCES} )
29
-
30
- # Include directories
31
- include_directories (${OPENSSL_INCLUDE_DIR} )
32
-
33
29
# Common libraries needed for both targets
34
30
set (COMMON_LIBS
35
31
duckdb_mbedtls
36
32
${OPENSSL_LIBRARIES}
37
- ZLIB::ZLIB
38
33
)
39
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
+
40
47
# Windows-specific libraries
41
48
if (MINGW )
42
- set (WIN_LIBS crypt32 ws2_32 wsock32 )
43
- list (APPEND COMMON_LIBS ${WIN_LIBS} )
49
+ set (WIN_LIBS crypt32 ws2_32 wsock32 )
50
+ list (APPEND COMMON_LIBS ${WIN_LIBS} )
44
51
endif ()
45
52
53
+ # Build extensions
54
+ build_static_extension (${TARGET_NAME} ${EXTENSION_SOURCES} )
55
+ build_loadable_extension (${TARGET_NAME} " " ${EXTENSION_SOURCES} )
56
+
57
+ # Include directories
58
+ include_directories (${OPENSSL_INCLUDE_DIR} )
59
+
46
60
# Link libraries
47
61
target_link_libraries (${LOADABLE_EXTENSION_NAME} ${COMMON_LIBS} )
48
62
target_link_libraries (${EXTENSION_NAME} ${COMMON_LIBS} )
49
63
50
64
install (
51
- TARGETS ${EXTENSION_NAME}
52
- EXPORT "${DUCKDB_EXPORT_SET} "
53
- LIBRARY DESTINATION "${INSTALL_LIB_DIR} "
54
- 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