mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
1a7727a254
A simple HelloWorld program with zero includes except iostream triggers a build of ca. 2000 source files. The reason is that ClickHouse's top-level CMakeLists.txt overrides "add_executable()" to link all binaries against "clickhouse_new_delete". This links against "clickhouse_common_io", which in turn has lots of 3rd party library dependencies ... Without linking "clickhouse_new_delete", the number of compiled files for "HelloWorld" goes down to ca. 70. As an example, the self-extracting-executable needs none of its current dependencies but other programs may also benefit. In order to restore access to the original "add_executable()", the overriding version is now prefixed. There is precedence for a "clickhouse_" prefix (as opposed to "ch_"), for example "clickhouse_split_debug_symbols". In general prefixing makes sense also because overriding CMake commands relies on undocumented behavior and is considered not-so-great practice (*). (*) https://crascit.com/2018/09/14/do-not-redefine-cmake-commands/
52 lines
1.8 KiB
CMake
52 lines
1.8 KiB
CMake
include(${ClickHouse_SOURCE_DIR}/cmake/split_debug_symbols.cmake)
|
|
|
|
set (CLICKHOUSE_ODBC_BRIDGE_SOURCES
|
|
ColumnInfoHandler.cpp
|
|
getIdentifierQuote.cpp
|
|
HandlerFactory.cpp
|
|
IdentifierQuoteHandler.cpp
|
|
MainHandler.cpp
|
|
ODBCBlockInputStream.cpp
|
|
ODBCBlockOutputStream.cpp
|
|
ODBCBridge.cpp
|
|
PingHandler.cpp
|
|
SchemaAllowedHandler.cpp
|
|
validateODBCConnectionString.cpp
|
|
odbc-bridge.cpp
|
|
)
|
|
|
|
if (OS_LINUX)
|
|
# clickhouse-odbc-bridge is always a separate binary.
|
|
# Reason: it must not export symbols from SSL, mariadb-client, etc. to not break ABI compatibility with ODBC drivers.
|
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-export-dynamic")
|
|
endif ()
|
|
|
|
clickhouse_add_executable(clickhouse-odbc-bridge ${CLICKHOUSE_ODBC_BRIDGE_SOURCES})
|
|
|
|
target_link_libraries(clickhouse-odbc-bridge PRIVATE
|
|
daemon
|
|
dbms
|
|
bridge
|
|
clickhouse_parsers
|
|
ch_contrib::nanodbc
|
|
ch_contrib::unixodbc
|
|
)
|
|
|
|
set_target_properties(clickhouse-odbc-bridge PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)
|
|
target_compile_options (clickhouse-odbc-bridge PRIVATE -Wno-reserved-id-macro -Wno-keyword-macro)
|
|
|
|
if (USE_GDB_ADD_INDEX)
|
|
add_custom_command(TARGET clickhouse-odbc-bridge POST_BUILD COMMAND ${GDB_ADD_INDEX_EXE} ../clickhouse-odbc-bridge COMMENT "Adding .gdb-index to clickhouse-odbc-bridge" VERBATIM)
|
|
endif()
|
|
|
|
if (SPLIT_DEBUG_SYMBOLS)
|
|
clickhouse_split_debug_symbols(TARGET clickhouse-odbc-bridge DESTINATION_DIR ${CMAKE_CURRENT_BINARY_DIR}/../${SPLITTED_DEBUG_SYMBOLS_DIR} BINARY_PATH ../clickhouse-odbc-bridge)
|
|
else()
|
|
clickhouse_make_empty_debug_info_for_nfpm(TARGET clickhouse-odbc-bridge DESTINATION_DIR ${CMAKE_CURRENT_BINARY_DIR}/../${SPLITTED_DEBUG_SYMBOLS_DIR})
|
|
install(TARGETS clickhouse-odbc-bridge RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT clickhouse)
|
|
endif()
|
|
|
|
if(ENABLE_TESTS)
|
|
add_subdirectory(tests)
|
|
endif()
|