Skip to content

Commit 14768f4

Browse files
committed
clickhouse-cpp scanner
1 parent 0bcdaf6 commit 14768f4

File tree

6 files changed

+454
-26
lines changed

6 files changed

+454
-26
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
url = https://github.com/duckdb/extension-ci-tools
99
branch = main
1010
update = merge
11+
[submodule "contribs/clickhouse-cpp"]
12+
path = contribs/clickhouse-cpp
13+
url = https://github.com/ClickHouse/clickhouse-cpp.git

chsql/CMakeLists.txt

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,70 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.12)
2+
23
# Set extension name here
34
set(TARGET_NAME chsql)
4-
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
5-
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
6-
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
5+
6+
project(${TARGET_NAME})
7+
8+
# Configure clickhouse-cpp options
9+
set(CH_CPP_BUILD_SHARED OFF CACHE BOOL "Build shared library")
10+
set(CH_CPP_BUILD_STATICALY_LINKED_LIB ON CACHE BOOL "Build static library")
11+
set(CH_CPP_BUILD_ONLY_LIB ON CACHE BOOL "Build only library")
12+
set(CH_CPP_WITH_OPENSSL ON CACHE BOOL "Use OpenSSL")
13+
14+
# Add clickhouse-cpp
15+
add_subdirectory(
16+
${CMAKE_CURRENT_SOURCE_DIR}/../contribs/clickhouse-cpp
17+
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-cpp
18+
EXCLUDE_FROM_ALL
19+
)
20+
21+
# Find OpenSSL package
722
find_package(OpenSSL REQUIRED)
23+
824
set(EXTENSION_NAME ${TARGET_NAME}_extension)
925
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
10-
project(${TARGET_NAME})
1126

1227
include_directories(
13-
./src/include
14-
./src
15-
${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/extension/parquet/include
16-
../duckdb/third_party/lz4
17-
../duckdb/third_party/parquet
18-
../duckdb/third_party/thrift
19-
../duckdb/third_party/snappy
20-
../duckdb/third_party/zstd/include
21-
../duckdb/third_party/mbedtls
22-
../duckdb/third_party/mbedtls/include
23-
../duckdb/third_party/brotli/include)
24-
set(EXTENSION_SOURCES src/chsql_extension.cpp src/duck_flock.cpp)
28+
./src/include
29+
./src
30+
${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/extension/parquet/include
31+
../duckdb/third_party/lz4
32+
../duckdb/third_party/parquet
33+
../duckdb/third_party/thrift
34+
../duckdb/third_party/snappy
35+
../duckdb/third_party/zstd/include
36+
../duckdb/third_party/mbedtls
37+
../duckdb/third_party/mbedtls/include
38+
../duckdb/third_party/brotli/include
39+
${CMAKE_CURRENT_SOURCE_DIR}/../contribs/clickhouse-cpp
40+
${CMAKE_CURRENT_SOURCE_DIR}/../contribs/clickhouse-cpp/contrib/absl
41+
)
42+
43+
# Update extension sources to include new file
44+
set(EXTENSION_SOURCES
45+
src/chsql_extension.cpp
46+
src/duck_flock.cpp
47+
src/clickhouse_scan.cpp
48+
)
49+
2550
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
2651
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
27-
# Link OpenSSL in both the static library as the loadable extension
28-
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
29-
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
52+
53+
# Link libraries using plain signature
54+
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto clickhouse-cpp-lib)
55+
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto clickhouse-cpp-lib)
56+
57+
# Install targets
3058
install(
31-
TARGETS ${EXTENSION_NAME}
32-
EXPORT "${DUCKDB_EXPORT_SET}"
33-
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
34-
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")
59+
TARGETS ${EXTENSION_NAME} clickhouse-cpp-lib
60+
EXPORT "${DUCKDB_EXPORT_SET}"
61+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
62+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
63+
)
64+
65+
# Make sure the export set includes clickhouse-cpp-lib
66+
export(
67+
TARGETS ${EXTENSION_NAME} clickhouse-cpp-lib
68+
NAMESPACE duckdb::
69+
FILE DuckDBExports.cmake
70+
)

0 commit comments

Comments
 (0)