2019-08-28 20:49:37 +00:00
|
|
|
# Set standard, system and compiler libraries explicitly.
|
|
|
|
# This is intended for more control of what we are linking.
|
|
|
|
|
|
|
|
set (DEFAULT_LIBS "-nodefaultlibs")
|
|
|
|
|
2019-08-30 16:50:43 +00:00
|
|
|
# We need builtins from Clang's RT even without libcxx - for ubsan+int128.
|
|
|
|
# See https://bugs.llvm.org/show_bug.cgi?id=16404
|
2019-10-30 07:01:53 +00:00
|
|
|
if (COMPILER_CLANG AND NOT (CMAKE_CROSSCOMPILING AND ARCH_AARCH64))
|
2021-04-01 15:38:16 +00:00
|
|
|
execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-libgcc-file-name --rtlib=compiler-rt OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2019-08-30 16:50:43 +00:00
|
|
|
else ()
|
|
|
|
set (BUILTINS_LIBRARY "-lgcc")
|
2019-08-28 20:49:37 +00:00
|
|
|
endif ()
|
|
|
|
|
2020-07-15 11:16:00 +00:00
|
|
|
if (OS_ANDROID)
|
2020-12-15 19:59:07 +00:00
|
|
|
# pthread and rt are included in libc
|
|
|
|
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -ldl")
|
2020-07-15 11:16:00 +00:00
|
|
|
else ()
|
2020-12-15 19:59:07 +00:00
|
|
|
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -lrt -lpthread -ldl")
|
2020-07-15 11:16:00 +00:00
|
|
|
endif ()
|
2019-08-30 16:50:43 +00:00
|
|
|
|
|
|
|
message(STATUS "Default libraries: ${DEFAULT_LIBS}")
|
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES ${DEFAULT_LIBS})
|
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES ${DEFAULT_LIBS})
|
|
|
|
|
2020-06-22 14:59:38 +00:00
|
|
|
# glibc-compatibility library relies to constant version of libc headers
|
2019-12-20 01:24:25 +00:00
|
|
|
# (because minor changes in function attributes between different glibc versions will introduce incompatibilities)
|
2019-12-20 12:35:41 +00:00
|
|
|
# This is for x86_64. For other architectures we have separate toolchains.
|
2020-05-14 17:42:32 +00:00
|
|
|
if (ARCH_AMD64 AND NOT_UNBUNDLED)
|
2019-12-20 12:35:41 +00:00
|
|
|
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${ClickHouse_SOURCE_DIR}/contrib/libc-headers/x86_64-linux-gnu ${ClickHouse_SOURCE_DIR}/contrib/libc-headers)
|
2019-12-20 15:48:01 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${ClickHouse_SOURCE_DIR}/contrib/libc-headers/x86_64-linux-gnu ${ClickHouse_SOURCE_DIR}/contrib/libc-headers)
|
2019-12-20 12:35:41 +00:00
|
|
|
endif ()
|
2019-12-20 01:24:25 +00:00
|
|
|
|
2019-08-28 20:49:37 +00:00
|
|
|
# Unfortunately '-pthread' doesn't work with '-nodefaultlibs'.
|
|
|
|
# Just make sure we have pthreads at all.
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2020-07-15 11:16:00 +00:00
|
|
|
if (NOT OS_ANDROID)
|
|
|
|
# Our compatibility layer doesn't build under Android, many errors in musl.
|
|
|
|
add_subdirectory(base/glibc-compatibility)
|
2020-10-26 01:54:35 +00:00
|
|
|
add_subdirectory(base/harmful)
|
2020-07-15 11:16:00 +00:00
|
|
|
endif ()
|
|
|
|
|
2019-08-30 13:28:02 +00:00
|
|
|
include (cmake/find/unwind.cmake)
|
|
|
|
include (cmake/find/cxx.cmake)
|
2019-08-28 20:49:37 +00:00
|
|
|
|
|
|
|
add_library(global-group INTERFACE)
|
|
|
|
target_link_libraries(global-group INTERFACE
|
|
|
|
-Wl,--start-group
|
|
|
|
$<TARGET_PROPERTY:global-libs,INTERFACE_LINK_LIBRARIES>
|
|
|
|
-Wl,--end-group
|
|
|
|
)
|
|
|
|
|
|
|
|
link_libraries(global-group)
|
|
|
|
|
2019-08-30 16:50:43 +00:00
|
|
|
# FIXME: remove when all contribs will get custom cmake lists
|
2019-08-28 20:49:37 +00:00
|
|
|
install(
|
|
|
|
TARGETS global-group global-libs
|
|
|
|
EXPORT global
|
|
|
|
)
|