Skip to content

Commit c40258c

Browse files
authored
Update CMakeLists.txt
1 parent dfec1c0 commit c40258c

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

CMakeLists.txt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ cmake_minimum_required(VERSION 3.5)
33
# Set extension name here
44
set(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
910
find_package(OpenSSL REQUIRED)
11+
find_package(ZLIB REQUIRED)
1012

1113
set(EXTENSION_NAME ${TARGET_NAME}_extension)
1214
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
1315

1416
project(${TARGET_NAME})
17+
1518
include_directories(src/include duckdb/third_party/httplib)
1619

1720
set(EXTENSION_SOURCES src/http_client_extension.cpp)
@@ -20,23 +23,30 @@ if(MINGW)
2023
set(OPENSSL_USE_STATIC_LIBS TRUE)
2124
endif()
2225

23-
# Find OpenSSL before building extensions
24-
find_package(OpenSSL REQUIRED)
25-
26+
# Build extensions
2627
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
2728
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
2829

30+
# Include directories
2931
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})
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
3341
if(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})
3844
endif()
3945

46+
# Link libraries
47+
target_link_libraries(${LOADABLE_EXTENSION_NAME} ${COMMON_LIBS})
48+
target_link_libraries(${EXTENSION_NAME} ${COMMON_LIBS})
49+
4050
install(
4151
TARGETS ${EXTENSION_NAME}
4252
EXPORT "${DUCKDB_EXPORT_SET}"

0 commit comments

Comments
 (0)