From d52f67d24e07751df356606bb6486cebdc91a914 Mon Sep 17 00:00:00 2001 From: alesapin Date: Wed, 29 Jul 2020 14:00:04 +0300 Subject: [PATCH] Fix abtesting build --- cmake/find/stats.cmake | 20 ++++++++++++++++++++ contrib/CMakeLists.txt | 6 ++++-- contrib/stats-cmake/CMakeLists.txt | 3 +-- src/Common/config.h.in | 1 + src/Functions/CMakeLists.txt | 4 +++- src/Functions/abtesting.cpp | 18 ++++++++++++++++-- src/Functions/abtesting.h | 7 ++++++- 7 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 cmake/find/stats.cmake diff --git a/cmake/find/stats.cmake b/cmake/find/stats.cmake new file mode 100644 index 00000000000..ef5b1a73659 --- /dev/null +++ b/cmake/find/stats.cmake @@ -0,0 +1,20 @@ +option(ENABLE_STATS "Enalbe StatsLib library" ${ENABLE_LIBRARIES}) + +if (ENABLE_STATS) + if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/stats") + message (WARNING "submodule contrib/stats is missing. to fix try run: \n git submodule update --init --recursive") + set (ENABLE_STATS 0) + set (USE_STATS 0) + elseif (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/gcem") + message (WARNING "submodule contrib/gcem is missing. to fix try run: \n git submodule update --init --recursive") + set (ENABLE_STATS 0) + set (USE_STATS 0) + else() + set(STATS_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/stats/include) + set(GCEM_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/gcem/include) + set (USE_STATS 1) + endif() +endif() + +message (STATUS "Using stats=${USE_STATS} : ${STATS_INCLUDE_DIR}") +message (STATUS "Using gcem=${USE_STATS}: ${GCEM_INCLUDE_DIR}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index dc0d37f5af5..b4ac383004b 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -306,6 +306,8 @@ if (USE_SENTRY) endif() add_subdirectory (fmtlib-cmake) -add_subdirectory (stats-cmake) -add_subdirectory (gcem) +if (USE_STATS) + add_subdirectory (stats-cmake) + add_subdirectory (gcem) +endif() diff --git a/contrib/stats-cmake/CMakeLists.txt b/contrib/stats-cmake/CMakeLists.txt index e6ee2c85b29..a159e85a0e3 100644 --- a/contrib/stats-cmake/CMakeLists.txt +++ b/contrib/stats-cmake/CMakeLists.txt @@ -1,6 +1,5 @@ -# The stats is a header-only library of probability density functions, +# The stats is a header-only library of probability density functions, # cumulative distribution functions, quantile functions, and random sampling methods. - set(STATS_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/stats/include) set(GCEM_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/gcem/include) diff --git a/src/Common/config.h.in b/src/Common/config.h.in index ff4e5e8c6b3..3a67b2a8f2c 100644 --- a/src/Common/config.h.in +++ b/src/Common/config.h.in @@ -12,4 +12,5 @@ #cmakedefine01 USE_CASSANDRA #cmakedefine01 USE_SENTRY #cmakedefine01 USE_GRPC +#cmakedefine01 USE_STATS #cmakedefine01 CLICKHOUSE_SPLIT_BINARY diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index 993376b1e50..a37fb386d4c 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -112,4 +112,6 @@ target_link_libraries(clickhouse_functions PRIVATE clickhouse_functions_url) add_subdirectory(array) target_link_libraries(clickhouse_functions PRIVATE clickhouse_functions_array) -target_link_libraries(clickhouse_functions PRIVATE stats) +if (USE_STATS) + target_link_libraries(clickhouse_functions PRIVATE stats) +endif() diff --git a/src/Functions/abtesting.cpp b/src/Functions/abtesting.cpp index 0152e403fb8..040630b36ac 100644 --- a/src/Functions/abtesting.cpp +++ b/src/Functions/abtesting.cpp @@ -1,4 +1,6 @@ -#if !defined(ARCADIA_BUILD) +#include + +#if !defined(ARCADIA_BUILD) && USE_STATS #include #include @@ -9,7 +11,6 @@ #include #include #include -#include #include #include @@ -304,4 +305,17 @@ void registerFunctionBayesAB(FunctionFactory & factory) } +#else + +namespace DB +{ + +class FunctionFactory; + +void registerFunctionBayesAB(FunctionFactory & /* factory */) +{ +} + +} + #endif diff --git a/src/Functions/abtesting.h b/src/Functions/abtesting.h index c39cbb71d7b..1e9b9747505 100644 --- a/src/Functions/abtesting.h +++ b/src/Functions/abtesting.h @@ -1,6 +1,10 @@ -#if !defined(ARCADIA_BUILD) #pragma once +#include + +#if !defined(ARCADIA_BUILD) && USE_STATS + + #include #include #include @@ -28,4 +32,5 @@ Variants bayesian_ab_test(String distribution, PODArray & xs, PODArray< String convertToJson(const PODArray & variant_names, const Variants & variants); } + #endif