generated from duckdb/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
68 lines (53 loc) · 1.75 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.5)
# Set extension name here
set(TARGET_NAME http_client)
# Make ZLIB support optional with default ON for desktop platforms and OFF for WASM
if(EMSCRIPTEN)
option(USE_ZLIB "Enable ZLIB compression support" OFF)
else()
option(USE_ZLIB "Enable ZLIB compression support" ON)
endif()
# Find OpenSSL before building extensions
find_package(OpenSSL 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)
if(MINGW)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif()
# Common libraries needed for both targets
set(COMMON_LIBS
duckdb_mbedtls
${OPENSSL_LIBRARIES}
)
# Handle ZLIB support
if(USE_ZLIB)
find_package(ZLIB)
if(ZLIB_FOUND)
add_compile_definitions(CPPHTTPLIB_ZLIB_SUPPORT)
list(APPEND COMMON_LIBS ZLIB::ZLIB)
message(STATUS "Building with ZLIB support")
else()
message(STATUS "ZLIB not found, building without ZLIB support")
endif()
endif()
# Windows-specific libraries
if(MINGW)
set(WIN_LIBS crypt32 ws2_32 wsock32)
list(APPEND COMMON_LIBS ${WIN_LIBS})
endif()
# Build extensions
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
# Include directories
include_directories(${OPENSSL_INCLUDE_DIR})
# 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}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")