From c343f85b641c7c9325455b31ebe39574add5de1d Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 23 May 2021 02:26:40 +0300 Subject: [PATCH] Do not built clickhouse-keeper w/o NuRaft Otherwise it will fail because of unused argument and unreachable code. --- programs/CMakeLists.txt | 28 ++++++++++++++++++++++++++-- programs/keeper/Keeper.cpp | 8 +------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 6fd4c2050b4..2af0331c70b 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -49,6 +49,12 @@ option (ENABLE_CLICKHOUSE_GIT_IMPORT "A tool to analyze Git repositories" option (ENABLE_CLICKHOUSE_KEEPER "ClickHouse alternative to ZooKeeper" ${ENABLE_CLICKHOUSE_ALL}) +if (NOT USE_NURAFT) + # RECONFIGURE_MESSAGE_LEVEL should not be used here, + # since USE_NURAFT is set to OFF for FreeBSD and Darwin. + message (STATUS "clickhouse-keeper will not be built (lack of NuRaft)") + set(ENABLE_CLICKHOUSE_KEEPER OFF) +endif() if (CLICKHOUSE_SPLIT_BINARY) option(ENABLE_CLICKHOUSE_INSTALL "Install ClickHouse without .deb/.rpm/.tgz packages (having the binary only)" OFF) @@ -259,7 +265,10 @@ add_subdirectory (obfuscator) add_subdirectory (install) add_subdirectory (git-import) add_subdirectory (bash-completion) -add_subdirectory (keeper) + +if (ENABLE_CLICKHOUSE_KEEPER) + add_subdirectory (keeper) +endif() if (ENABLE_CLICKHOUSE_ODBC_BRIDGE) add_subdirectory (odbc-bridge) @@ -278,7 +287,18 @@ if (CLICKHOUSE_ONE_SHARED) endif() if (CLICKHOUSE_SPLIT_BINARY) - set (CLICKHOUSE_ALL_TARGETS clickhouse-server clickhouse-client clickhouse-local clickhouse-benchmark clickhouse-extract-from-config clickhouse-compressor clickhouse-format clickhouse-obfuscator clickhouse-git-import clickhouse-copier clickhouse-keeper) + set (CLICKHOUSE_ALL_TARGETS + clickhouse-server + clickhouse-client + clickhouse-local + clickhouse-benchmark + clickhouse-extract-from-config + clickhouse-compressor + clickhouse-format + clickhouse-obfuscator + clickhouse-git-import + clickhouse-copier + ) if (ENABLE_CLICKHOUSE_ODBC_BRIDGE) list (APPEND CLICKHOUSE_ALL_TARGETS clickhouse-odbc-bridge) @@ -288,6 +308,10 @@ if (CLICKHOUSE_SPLIT_BINARY) list (APPEND CLICKHOUSE_ALL_TARGETS clickhouse-library-bridge) endif () + if (ENABLE_CLICKHOUSE_KEEPER) + list (APPEND CLICKHOUSE_ALL_TARGETS clickhouse-keeper) + endif () + set_target_properties(${CLICKHOUSE_ALL_TARGETS} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) add_custom_target (clickhouse-bundle ALL DEPENDS ${CLICKHOUSE_ALL_TARGETS}) diff --git a/programs/keeper/Keeper.cpp b/programs/keeper/Keeper.cpp index b9d87ba7fdb..8b35ec12850 100644 --- a/programs/keeper/Keeper.cpp +++ b/programs/keeper/Keeper.cpp @@ -30,9 +30,7 @@ # include #endif -#if USE_NURAFT -# include -#endif +#include #if defined(OS_LINUX) # include @@ -357,7 +355,6 @@ int Keeper::main(const std::vector & /*args*/) auto servers = std::make_shared>(); -#if USE_NURAFT /// Initialize test keeper RAFT. Do nothing if no nu_keeper_server in config. global_context->initializeKeeperStorageDispatcher(); for (const auto & listen_host : listen_hosts) @@ -398,9 +395,6 @@ int Keeper::main(const std::vector & /*args*/) #endif }); } -#else - throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "ClickHouse keeper built without NuRaft library. Cannot use coordination."); -#endif for (auto & server : *servers) server.start();