@@ -3,15 +3,18 @@ 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+ # Add ZLIB definition for httplib
7+ add_compile_definitions (CPPHTTPLIB_ZLIB_SUPPORT)
8+
9+ # Find required packages
910find_package (OpenSSL REQUIRED)
11+ find_package (ZLIB REQUIRED)
1012
1113set (EXTENSION_NAME ${TARGET_NAME} _extension)
1214set (LOADABLE_EXTENSION_NAME ${TARGET_NAME} _loadable_extension)
1315
1416project (${TARGET_NAME} )
17+
1518include_directories (src/include duckdb/third_party/httplib)
1619
1720set (EXTENSION_SOURCES src/http_client_extension.cpp)
@@ -20,23 +23,30 @@ if(MINGW)
2023 set (OPENSSL_USE_STATIC_LIBS TRUE )
2124endif ()
2225
23- # Find OpenSSL before building extensions
24- find_package (OpenSSL REQUIRED)
25-
26+ # Build extensions
2627build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES} )
2728build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES} )
2829
30+ # Include directories
2931include_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} )
3232
33+ # Common libraries needed for both targets
34+ set (COMMON_LIBS
35+ duckdb_mbedtls
36+ ${OPENSSL_LIBRARIES}
37+ ZLIB::ZLIB
38+ )
39+
40+ # Windows-specific libraries
3341if (MINGW)
3442 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} )
43+ list (APPEND COMMON_LIBS ${WIN_LIBS} )
3844endif ()
3945
46+ # Link libraries
47+ target_link_libraries (${LOADABLE_EXTENSION_NAME} ${COMMON_LIBS} )
48+ target_link_libraries (${EXTENSION_NAME} ${COMMON_LIBS} )
49+
4050install (
4151 TARGETS ${EXTENSION_NAME}
4252 EXPORT "${DUCKDB_EXPORT_SET} "
0 commit comments