From 6a721baa59ccda14ea24a14aa601656eb5274fd3 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Tue, 18 Jan 2022 01:13:47 +0300 Subject: [PATCH] Remove unbundled datasketches support --- CMakeLists.txt | 1 - cmake/find/datasketches.cmake | 29 ------------------- contrib/CMakeLists.txt | 1 + contrib/datasketches-cpp-cmake/CMakeLists.txt | 14 +++++++++ src/CMakeLists.txt | 4 +-- src/configure_config.cmake | 3 ++ 6 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 cmake/find/datasketches.cmake create mode 100644 contrib/datasketches-cpp-cmake/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index a1072e3d9e9..d35f2faeec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,7 +489,6 @@ include (GNUInstallDirs) include (cmake/find/llvm.cmake) include (cmake/find/s3.cmake) include (cmake/find/nlp.cmake) -include (cmake/find/datasketches.cmake) # Need to process before "contrib" dir: include (cmake/find/mysqlclient.cmake) diff --git a/cmake/find/datasketches.cmake b/cmake/find/datasketches.cmake deleted file mode 100644 index 3d0bb1d1f95..00000000000 --- a/cmake/find/datasketches.cmake +++ /dev/null @@ -1,29 +0,0 @@ -option (ENABLE_DATASKETCHES "Enable DataSketches" ${ENABLE_LIBRARIES}) - -if (ENABLE_DATASKETCHES) - -option (USE_INTERNAL_DATASKETCHES_LIBRARY "Set to FALSE to use system DataSketches library instead of bundled" ON) - -if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/datasketches-cpp/theta/CMakeLists.txt") - if (USE_INTERNAL_DATASKETCHES_LIBRARY) - message(WARNING "submodule contrib/datasketches-cpp is missing. to fix try run: \n git submodule update --init") - endif() - set(MISSING_INTERNAL_DATASKETCHES_LIBRARY 1) - set(USE_INTERNAL_DATASKETCHES_LIBRARY 0) -endif() - -if (USE_INTERNAL_DATASKETCHES_LIBRARY) - set(DATASKETCHES_LIBRARY theta) - set(DATASKETCHES_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/datasketches-cpp/common/include" "${ClickHouse_SOURCE_DIR}/contrib/datasketches-cpp/theta/include") -elseif (NOT MISSING_INTERNAL_DATASKETCHES_LIBRARY) - find_library(DATASKETCHES_LIBRARY theta) - find_path(DATASKETCHES_INCLUDE_DIR NAMES theta_sketch.hpp PATHS ${DATASKETCHES_INCLUDE_PATHS}) -endif() - -if (DATASKETCHES_LIBRARY AND DATASKETCHES_INCLUDE_DIR) - set(USE_DATASKETCHES 1) -endif() - -endif() - -message (STATUS "Using datasketches=${USE_DATASKETCHES}: ${DATASKETCHES_INCLUDE_DIR} : ${DATASKETCHES_LIBRARY}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 45c6bb62091..e53ea42ddd3 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -139,6 +139,7 @@ add_subdirectory (libpqxx-cmake) add_subdirectory (libpq-cmake) add_subdirectory (nuraft-cmake) add_subdirectory (fast_float-cmake) +add_subdirectory (datasketches-cpp-cmake) if (USE_NLP) add_subdirectory(libstemmer-c-cmake) diff --git a/contrib/datasketches-cpp-cmake/CMakeLists.txt b/contrib/datasketches-cpp-cmake/CMakeLists.txt new file mode 100644 index 00000000000..b12a88ad57b --- /dev/null +++ b/contrib/datasketches-cpp-cmake/CMakeLists.txt @@ -0,0 +1,14 @@ +option (ENABLE_DATASKETCHES "Enable DataSketches" ${ENABLE_LIBRARIES}) + +if (NOT ENABLE_DATASKETCHES) + message(STATUS "Not using DataSketches") + return() +endif() + +set(DATASKETCHES_LIBRARY theta) +add_library(_datasketches INTERFACE) +target_include_directories(_datasketches SYSTEM BEFORE INTERFACE + "${ClickHouse_SOURCE_DIR}/contrib/datasketches-cpp/common/include" + "${ClickHouse_SOURCE_DIR}/contrib/datasketches-cpp/theta/include") + +add_library(ch_contrib::datasketches ALIAS _datasketches) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e8512959cf..ea532e14f95 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -485,8 +485,8 @@ if (TARGET ch_contrib::libpqxx) dbms_target_link_libraries(PUBLIC ch_contrib::libpqxx) endif() -if (USE_DATASKETCHES) - target_include_directories (clickhouse_aggregate_functions SYSTEM BEFORE PRIVATE ${DATASKETCHES_INCLUDE_DIR}) +if (TARGET ch_contrib::datasketches) + target_link_libraries (clickhouse_aggregate_functions PRIVATE ch_contrib::datasketches) endif () target_link_libraries (clickhouse_common_io PRIVATE ch_contrib::lz4) diff --git a/src/configure_config.cmake b/src/configure_config.cmake index 18925ac6be2..7e191478a44 100644 --- a/src/configure_config.cmake +++ b/src/configure_config.cmake @@ -67,3 +67,6 @@ endif() if (TARGET ch_contrib::sentry) set(USE_SENTRY 1) endif() +if (TARGET ch_contrib::datasketches) + set(USE_DATASKETCHES 1) +endif()