Skip to content

Commit

Permalink
Update CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
lmangani authored Nov 16, 2024
1 parent dfec1c0 commit c40258c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ cmake_minimum_required(VERSION 3.5)
# Set extension name here
set(TARGET_NAME http_client)

# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
# Add ZLIB definition for httplib
add_compile_definitions(CPPHTTPLIB_ZLIB_SUPPORT)

# Find required packages
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)

set(EXTENSION_NAME ${TARGET_NAME}_extension)
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)

project(${TARGET_NAME})

include_directories(src/include duckdb/third_party/httplib)

set(EXTENSION_SOURCES src/http_client_extension.cpp)
Expand All @@ -20,23 +23,30 @@ if(MINGW)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()

# Find OpenSSL before building extensions
find_package(OpenSSL REQUIRED)

# Build extensions
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})

# Include directories
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(${LOADABLE_EXTENSION_NAME} duckdb_mbedtls ${OPENSSL_LIBRARIES})
target_link_libraries(${EXTENSION_NAME} duckdb_mbedtls ${OPENSSL_LIBRARIES})

# Common libraries needed for both targets
set(COMMON_LIBS
duckdb_mbedtls
${OPENSSL_LIBRARIES}
ZLIB::ZLIB
)

# Windows-specific libraries
if(MINGW)
set(WIN_LIBS crypt32 ws2_32 wsock32)
find_package(ZLIB)
target_link_libraries(${LOADABLE_EXTENSION_NAME} ZLIB::ZLIB ${WIN_LIBS})
target_link_libraries(${EXTENSION_NAME} ZLIB::ZLIB ${WIN_LIBS})
list(APPEND COMMON_LIBS ${WIN_LIBS})
endif()

# Link libraries
target_link_libraries(${LOADABLE_EXTENSION_NAME} ${COMMON_LIBS})
target_link_libraries(${EXTENSION_NAME} ${COMMON_LIBS})

install(
TARGETS ${EXTENSION_NAME}
EXPORT "${DUCKDB_EXPORT_SET}"
Expand Down

0 comments on commit c40258c

Please sign in to comment.