11add_compile_options ("$<$<OR :$<COMPILE_LANGUAGE :C >,$<COMPILE_LANGUAGE :CXX >>:${COVERAGE_FLAGS} >" )
22
3+ if (USE_CLANG_TIDY)
4+ set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH} " )
5+ endif ()
6+
37include (${ClickHouse_SOURCE_DIR } /cmake/split_debug_symbols.cmake )
48
9+ # The `clickhouse` binary is a multi purpose tool that contains multiple execution modes (client, server, etc.),
10+ # So client/server/... is just a symlink to `clickhouse` binary.
11+ #
12+ # But, there are several components that requires extra libraries, like keeper
13+ # requires NuRaft, that regular binary does not requires, so you can disable
14+ # compilation of this components.
15+ #
16+ # If you do not know what modes you need, turn then all.
17+ option (ENABLE_CLICKHOUSE_ALL "Enable all ClickHouse modes by default" ON )
18+
19+ # https://presentations.clickhouse.com/matemarketing_2020/
20+ option (ENABLE_CLICKHOUSE_GIT_IMPORT "A tool to analyze Git repositories" ${ENABLE_CLICKHOUSE_ALL} )
21+
22+ option (ENABLE_CLICKHOUSE_KEEPER "ClickHouse alternative to ZooKeeper" ${ENABLE_CLICKHOUSE_ALL} )
23+
24+ option (ENABLE_CLICKHOUSE_KEEPER_CONVERTER "Util allows to convert ZooKeeper logs and snapshots into clickhouse-keeper snapshot" ${ENABLE_CLICKHOUSE_ALL} )
25+
26+ option (ENABLE_CLICKHOUSE_KEEPER_CLIENT "ClickHouse Keeper Client" ${ENABLE_CLICKHOUSE_ALL} )
27+
28+ if (NOT ENABLE_NURAFT)
29+ # RECONFIGURE_MESSAGE_LEVEL should not be used here,
30+ # since ENABLE_NURAFT is set to OFF for FreeBSD and Darwin.
31+ message (STATUS "clickhouse-keeper and clickhouse-keeper-converter will not be built (lack of NuRaft)" )
32+ set (ENABLE_CLICKHOUSE_KEEPER OFF )
33+ set (ENABLE_CLICKHOUSE_KEEPER_CONVERTER OFF )
34+ endif ()
35+
36+ message (STATUS "ClickHouse extra components:" )
37+
38+ if (ENABLE_CLICKHOUSE_SELF_EXTRACTING)
39+ message (STATUS "Self-extracting executable: ON" )
40+ else ()
41+ message (STATUS "Self-extracting executable: OFF" )
42+ endif ()
43+
44+ if (ENABLE_CLICKHOUSE_KEEPER_CONVERTER)
45+ message (STATUS "ClickHouse keeper-converter mode: ON" )
46+ else ()
47+ message (STATUS "ClickHouse keeper-converter mode: OFF" )
48+ endif ()
49+
50+ if (ENABLE_CLICKHOUSE_KEEPER)
51+ message (STATUS "ClickHouse Keeper: ON" )
52+ else ()
53+ message (STATUS "ClickHouse Keeper: OFF" )
54+ endif ()
55+
56+ if (ENABLE_CLICKHOUSE_KEEPER_CLIENT)
57+ message (STATUS "ClickHouse keeper-client mode: ON" )
58+ else ()
59+ message (STATUS "ClickHouse keeper-client mode: OFF" )
60+ endif ()
61+
562configure_file (config_tools.h.in ${CONFIG_INCLUDE_PATH} /config_tools.h )
663
764macro (clickhouse_target_link_split_lib target name )
@@ -35,7 +92,44 @@ macro(clickhouse_program_add name)
3592 clickhouse_program_add_library (${name} )
3693endmacro ()
3794
95+ add_subdirectory (bash-completion )
96+ add_subdirectory (benchmark )
97+ add_subdirectory (check-marks )
98+ add_subdirectory (checksum-for-compressed-block )
99+ add_subdirectory (client )
100+ add_subdirectory (compressor )
101+ add_subdirectory (disks )
102+ add_subdirectory (extract-from-config )
103+ add_subdirectory (format )
104+ add_subdirectory (fst-dump-tree )
105+ add_subdirectory (git-import )
106+ add_subdirectory (install )
107+ add_subdirectory (keeper-bench )
108+ add_subdirectory (keeper-data-dumper )
109+ add_subdirectory (keeper-utils )
38110add_subdirectory (local )
111+ add_subdirectory (obfuscator )
112+ add_subdirectory (server )
113+ add_subdirectory (static -files-disk-uploader )
114+ add_subdirectory (su )
115+ add_subdirectory (zookeeper-dump-tree )
116+ add_subdirectory (zookeeper-remove-by-list )
117+
118+ if (ENABLE_CLICKHOUSE_KEEPER_CONVERTER)
119+ add_subdirectory (keeper-converter )
120+ endif ()
121+
122+ if (ENABLE_CLICKHOUSE_KEEPER_CLIENT)
123+ add_subdirectory (keeper-client )
124+ endif ()
125+
126+ if (ENABLE_CLICKHOUSE_KEEPER)
127+ add_subdirectory (keeper )
128+ endif ()
129+
130+ if (ENABLE_CLICKHOUSE_SELF_EXTRACTING AND NOT ENABLE_DUMMY_LAUNCHERS)
131+ add_subdirectory (self-extracting )
132+ endif ()
39133
40134clickhouse_add_executable (clickhouse main.cpp )
41135
@@ -52,12 +146,24 @@ if (APPLE)
52146 target_link_libraries (clickhouse PRIVATE iconv )
53147endif ()
54148
149+ if (ENABLE_CLICKHOUSE_KEEPER)
150+ clickhouse_target_link_split_lib (clickhouse keeper )
151+ endif ()
152+ if (ENABLE_CLICKHOUSE_KEEPER_CONVERTER)
153+ clickhouse_target_link_split_lib (clickhouse keeper-converter )
154+ endif ()
155+ if (ENABLE_CLICKHOUSE_KEEPER_CLIENT)
156+ clickhouse_target_link_split_lib (clickhouse keeper-client )
157+ endif ()
158+ clickhouse_target_link_split_lib (clickhouse install )
159+
55160macro (clickhouse_program_alias alias )
56161 message (STATUS "Adding alias ${alias} " )
57162 add_custom_command (TARGET clickhouse POST_BUILD COMMAND ${CMAKE_COMMAND } -E create_symlink clickhouse ${alias} )
58163 install (FILES "${CMAKE_CURRENT_BINARY_DIR } /${alias} " DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)
59164endmacro ()
60165
166+ set (CLICKHOUSE_BUNDLE)
61167function (clickhouse_program_install name lib_name )
62168 clickhouse_target_link_split_lib (clickhouse ${lib_name} )
63169 add_custom_command (TARGET clickhouse POST_BUILD COMMAND ${CMAKE_COMMAND } -E create_symlink clickhouse ${name} )
@@ -68,4 +174,110 @@ function(clickhouse_program_install name lib_name)
68174 endforeach ()
69175endfunction ()
70176
177+ if (ENABLE_CLICKHOUSE_SELF_EXTRACTING)
178+ list (APPEND CLICKHOUSE_BUNDLE self-extracting)
179+ endif ()
180+
181+ if (TARGET ch_rust::chdig)
182+ clickhouse_program_alias (clickhouse-chdig )
183+ clickhouse_program_alias (chdig )
184+ else ()
185+ message (STATUS "Adding dummy chdig targets (for nfpm)" )
186+ foreach (chdig_path ${CMAKE_BINARY_DIR } /chdig ${CMAKE_BINARY_DIR } /clickhouse-chdig)
187+ file (GENERATE OUTPUT ${chdig_path} CONTENT "#!/usr/bin/env sh\n echo chdig is not enabled in this ClickHouse build >&2 && exit 1\n " )
188+ install (FILES ${chdig_path}
189+ DESTINATION ${CMAKE_INSTALL_BINDIR}
190+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
191+ GROUP_READ GROUP_EXECUTE
192+ WORLD_READ WORLD_EXECUTE
193+ )
194+ endforeach ()
195+ endif ()
196+
197+ clickhouse_program_install (clickhouse-benchmark benchmark )
198+ clickhouse_program_install (clickhouse-check-marks check-marks )
199+ clickhouse_program_install (clickhouse-checksum-for-compressed-block checksum-for-compressed-block )
200+ clickhouse_program_install (clickhouse-client client chc )
201+ clickhouse_program_install (clickhouse-compressor compressor )
202+ clickhouse_program_install (clickhouse-disks disks )
203+ clickhouse_program_install (clickhouse-extract-from-config extract-from-config )
204+ clickhouse_program_install (clickhouse-format format )
205+ clickhouse_program_install (clickhouse-fst-dump-tree fst-dump-tree )
206+ clickhouse_program_install (clickhouse-git-import git-import )
71207clickhouse_program_install (clickhouse-local local chl ch )
208+ clickhouse_program_install (clickhouse-obfuscator obfuscator )
209+ clickhouse_program_install (clickhouse-server server )
210+ clickhouse_program_install (clickhouse-static-files-disk-uploader static -files-disk-uploader )
211+ clickhouse_program_install (clickhouse-su su )
212+ clickhouse_program_install (clickhouse-zookeeper-dump-tree zookeeper-dump-tree )
213+ clickhouse_program_install (clickhouse-zookeeper-remove-by-list zookeeper-remove-by-list )
214+
215+ if (TARGET ch_contrib::nuraft)
216+ clickhouse_program_install (clickhouse-keeper-data-dumper keeper-data-dumper )
217+ clickhouse_program_install (clickhouse-keeper-utils keeper-utils )
218+ endif ()
219+
220+ if (TARGET ch_contrib::rapidjson AND TARGET ch_contrib::nuraft)
221+ clickhouse_program_install (clickhouse-keeper-bench keeper-bench )
222+ endif ()
223+
224+ if (ENABLE_CLICKHOUSE_KEEPER)
225+ if (NOT BUILD_STANDALONE_KEEPER)
226+ add_custom_command (TARGET clickhouse POST_BUILD COMMAND ${CMAKE_COMMAND } -E create_symlink clickhouse clickhouse-keeper )
227+ install (FILES "${CMAKE_CURRENT_BINARY_DIR } /clickhouse-keeper" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)
228+ clickhouse_make_empty_debug_info_for_nfpm (TARGET clickhouse BINARY clickhouse-keeper DESTINATION_DIR ${CMAKE_CURRENT_BINARY_DIR } /../${SPLIT_DEBUG_SYMBOLS_DIR} )
229+ endif ()
230+
231+ # otherwise we don't build keeper
232+ if (BUILD_STANDALONE_KEEPER)
233+ list (APPEND CLICKHOUSE_BUNDLE clickhouse-keeper)
234+ endif ()
235+ endif ()
236+ if (ENABLE_CLICKHOUSE_KEEPER_CONVERTER)
237+ add_custom_command (TARGET clickhouse POST_BUILD COMMAND ${CMAKE_COMMAND } -E create_symlink clickhouse clickhouse-keeper-converter )
238+ install (FILES "${CMAKE_CURRENT_BINARY_DIR } /clickhouse-keeper-converter" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)
239+ endif ()
240+ if (ENABLE_CLICKHOUSE_KEEPER_CLIENT)
241+ if (NOT BUILD_STANDALONE_KEEPER)
242+ add_custom_command (TARGET clickhouse POST_BUILD COMMAND ${CMAKE_COMMAND } -E create_symlink clickhouse clickhouse-keeper-client )
243+ install (FILES "${CMAKE_CURRENT_BINARY_DIR } /clickhouse-keeper-client" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)
244+ endif ()
245+ endif ()
246+
247+ add_custom_target (clickhouse-bundle ALL DEPENDS ${CLICKHOUSE_BUNDLE} )
248+
249+ if (USE_BINARY_HASH)
250+ add_custom_command (TARGET clickhouse POST_BUILD COMMAND ./clickhouse hash-binary > hash && ${OBJCOPY_PATH} --add-section .clickhouse.hash=hash clickhouse COMMENT "Adding section '.clickhouse.hash' to clickhouse binary" VERBATIM )
251+ endif ()
252+
253+ if (CHECK_LARGE_OBJECT_SIZES)
254+ add_custom_command (TARGET clickhouse POST_BUILD
255+ COMMAND "${CMAKE_SOURCE_DIR } /utils/check-large-objects.sh" "${CMAKE_BINARY_DIR } " )
256+ endif ()
257+
258+ if (SPLIT_DEBUG_SYMBOLS)
259+ clickhouse_split_debug_symbols (TARGET clickhouse DESTINATION_DIR ${CMAKE_CURRENT_BINARY_DIR } /${SPLIT_DEBUG_SYMBOLS_DIR} BINARY_PATH clickhouse )
260+ else ()
261+ clickhouse_make_empty_debug_info_for_nfpm (TARGET clickhouse BINARY clickhouse DESTINATION_DIR ${CMAKE_CURRENT_BINARY_DIR } /${SPLIT_DEBUG_SYMBOLS_DIR} )
262+ install (TARGETS clickhouse RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)
263+ endif ()
264+
265+ if (BUILD_STRIPPED_BINARY)
266+ add_custom_target (clickhouse-stripped ALL
267+ COMMAND "${STRIP_PATH} " -o "${CMAKE_CURRENT_BINARY_DIR } /clickhouse-stripped" --strip-debug --remove-section=.comment --remove-section=.note "${CMAKE_CURRENT_BINARY_DIR } /clickhouse"
268+ DEPENDS clickhouse
269+ COMMENT "Stripping clickhouse binary" VERBATIM )
270+ endif ()
271+
272+ if (ENABLE_TESTS)
273+ set (CLICKHOUSE_UNIT_TESTS_TARGETS unit_tests_dbms)
274+ add_custom_target (clickhouse-tests ALL DEPENDS ${CLICKHOUSE_UNIT_TESTS_TARGETS} )
275+ add_dependencies (clickhouse-bundle clickhouse-tests )
276+ endif ()
277+
278+ if (TARGET ch_contrib::protobuf)
279+ get_property (google_proto_files TARGET ch_contrib::protobuf PROPERTY google_proto_files)
280+ foreach (proto_file IN LISTS google_proto_files)
281+ install (FILES ${proto_file} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /clickhouse/protos/google/protobuf)
282+ endforeach ()
283+ endif ()
0 commit comments