ClickHouse/programs/server/CMakeLists.txt

67 lines
2.7 KiB
CMake
Raw Normal View History

2019-03-04 17:47:31 +00:00
set(CLICKHOUSE_SERVER_SOURCES
MetricsTransmitter.cpp
Server.cpp
)
2020-09-25 01:45:47 +00:00
if (OS_LINUX)
2020-10-20 00:28:33 +00:00
set (LINK_RESOURCE_LIB INTERFACE "-Wl,${WHOLE_ARCHIVE} $<TARGET_FILE:clickhouse_server_configs> -Wl,${NO_WHOLE_ARCHIVE}")
2020-08-09 02:16:55 +00:00
endif ()
set (CLICKHOUSE_SERVER_LINK
PRIVATE
clickhouse_aggregate_functions
clickhouse_common_config
clickhouse_common_io
clickhouse_common_zookeeper
clickhouse_dictionaries
clickhouse_functions
clickhouse_parsers
clickhouse_storages_system
clickhouse_table_functions
string_utils
2020-10-20 00:28:33 +00:00
${LINK_RESOURCE_LIB}
2020-08-08 03:42:42 +00:00
PUBLIC
daemon
)
2019-03-04 17:47:31 +00:00
clickhouse_program_add(server)
2018-06-05 20:09:51 +00:00
2020-08-08 03:42:42 +00:00
install(FILES config.xml users.xml DESTINATION ${CLICKHOUSE_ETC_DIR}/clickhouse-server COMPONENT clickhouse)
2020-08-08 23:54:38 +00:00
# TODO We actually need this on Mac, FreeBSD.
if (OS_LINUX)
2020-08-08 23:41:34 +00:00
# Embed default config files as a resource into the binary.
# This is needed for two purposes:
# 1. Allow to run the binary without download of any other files.
# 2. Allow to implement "sudo clickhouse install" tool.
2020-10-20 00:28:33 +00:00
foreach(RESOURCE_FILE config.xml users.xml embedded.xml play.html)
set(RESOURCE_OBJ ${RESOURCE_FILE}.o)
set(RESOURCE_OBJS ${RESOURCE_OBJS} ${RESOURCE_OBJ})
2020-08-08 23:41:34 +00:00
# https://stackoverflow.com/questions/14776463/compile-and-add-an-object-file-from-a-binary-with-cmake
# PPC64LE fails to do this with objcopy, use ld or lld instead
if (ARCH_PPC64LE)
add_custom_command(OUTPUT ${RESOURCE_OBJ}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_LINKER} -m elf64lppc -r -b binary -o ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_OBJ} ${RESOURCE_FILE})
else()
add_custom_command(OUTPUT ${RESOURCE_OBJ}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${OBJCOPY_PATH} -I binary ${OBJCOPY_ARCH_OPTIONS} ${RESOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_OBJ}
COMMAND ${OBJCOPY_PATH} --rename-section .data=.rodata,alloc,load,readonly,data,contents
${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_OBJ} ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_OBJ})
endif()
2020-10-20 00:28:33 +00:00
set_source_files_properties(${RESOURCE_OBJ} PROPERTIES EXTERNAL_OBJECT true GENERATED true)
endforeach(RESOURCE_FILE)
2020-08-08 23:41:34 +00:00
2020-10-20 00:28:33 +00:00
add_library(clickhouse_server_configs STATIC ${RESOURCE_OBJS})
2020-08-08 23:41:34 +00:00
set_target_properties(clickhouse_server_configs PROPERTIES LINKER_LANGUAGE C)
# whole-archive prevents symbols from being discarded for unknown reason
# CMake can shuffle each of target_link_libraries arguments with other
# libraries in linker command. To avoid this we hardcode whole-archive
# library into single string.
add_dependencies(clickhouse-server-lib clickhouse_server_configs)
endif ()