Skip to content

Commit

Permalink
clickhouse-cpp scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
lmangani committed Dec 31, 2024
1 parent 0bcdaf6 commit 14768f4
Show file tree
Hide file tree
Showing 6 changed files with 454 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
url = https://github.com/duckdb/extension-ci-tools
branch = main
update = merge
[submodule "contribs/clickhouse-cpp"]
path = contribs/clickhouse-cpp
url = https://github.com/ClickHouse/clickhouse-cpp.git
84 changes: 60 additions & 24 deletions chsql/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,70 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.12)

# Set extension name here
set(TARGET_NAME chsql)
# 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..

project(${TARGET_NAME})

# Configure clickhouse-cpp options
set(CH_CPP_BUILD_SHARED OFF CACHE BOOL "Build shared library")
set(CH_CPP_BUILD_STATICALY_LINKED_LIB ON CACHE BOOL "Build static library")
set(CH_CPP_BUILD_ONLY_LIB ON CACHE BOOL "Build only library")
set(CH_CPP_WITH_OPENSSL ON CACHE BOOL "Use OpenSSL")

# Add clickhouse-cpp
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/../contribs/clickhouse-cpp
${CMAKE_CURRENT_BINARY_DIR}/clickhouse-cpp
EXCLUDE_FROM_ALL
)

# Find OpenSSL package
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
./src
${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/extension/parquet/include
../duckdb/third_party/lz4
../duckdb/third_party/parquet
../duckdb/third_party/thrift
../duckdb/third_party/snappy
../duckdb/third_party/zstd/include
../duckdb/third_party/mbedtls
../duckdb/third_party/mbedtls/include
../duckdb/third_party/brotli/include)
set(EXTENSION_SOURCES src/chsql_extension.cpp src/duck_flock.cpp)
./src/include
./src
${CMAKE_CURRENT_SOURCE_DIR}/../duckdb/extension/parquet/include
../duckdb/third_party/lz4
../duckdb/third_party/parquet
../duckdb/third_party/thrift
../duckdb/third_party/snappy
../duckdb/third_party/zstd/include
../duckdb/third_party/mbedtls
../duckdb/third_party/mbedtls/include
../duckdb/third_party/brotli/include
${CMAKE_CURRENT_SOURCE_DIR}/../contribs/clickhouse-cpp
${CMAKE_CURRENT_SOURCE_DIR}/../contribs/clickhouse-cpp/contrib/absl
)

# Update extension sources to include new file
set(EXTENSION_SOURCES
src/chsql_extension.cpp
src/duck_flock.cpp
src/clickhouse_scan.cpp
)

build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
# Link OpenSSL in both the static library as the loadable extension
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)

# Link libraries using plain signature
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto clickhouse-cpp-lib)
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto clickhouse-cpp-lib)

# Install targets
install(
TARGETS ${EXTENSION_NAME}
EXPORT "${DUCKDB_EXPORT_SET}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")
TARGETS ${EXTENSION_NAME} clickhouse-cpp-lib
EXPORT "${DUCKDB_EXPORT_SET}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
)

# Make sure the export set includes clickhouse-cpp-lib
export(
TARGETS ${EXTENSION_NAME} clickhouse-cpp-lib
NAMESPACE duckdb::
FILE DuckDBExports.cmake
)
Loading

0 comments on commit 14768f4

Please sign in to comment.