-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
454 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Oops, something went wrong.