From c430af5fb8f93558c0af0a37c739faf0493d7032 Mon Sep 17 00:00:00 2001 From: proller Date: Sun, 21 Jan 2018 02:23:19 +0300 Subject: [PATCH] Freebsd fixes --- CMakeLists.txt | 12 ++++++++---- cmake/find_execinfo.cmake | 2 +- cmake/find_llvm.cmake | 2 +- cmake/find_rdkafka.cmake | 9 +++++++-- cmake/find_zlib.cmake | 2 +- dbms/CMakeLists.txt | 2 +- dbms/src/IO/tests/CMakeLists.txt | 2 +- dbms/src/Interpreters/CMakeLists.txt | 2 +- libs/libcommon/cmake/find_gperftools.cmake | 6 +++--- utils/iotest/CMakeLists.txt | 2 +- 10 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f534a78a83..495b4cb7e70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,6 @@ else () message (WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang 5+ and GCC 7+.") endif () -if (CMAKE_SYSTEM MATCHES "FreeBSD") - set (PLATFORM_EXTRA_CXX_FLAG "-DCLOCK_MONOTONIC_COARSE=CLOCK_MONOTONIC_FAST") -endif () # Write compile_commands.json set(CMAKE_EXPORT_COMPILE_COMMANDS 1) @@ -51,6 +48,13 @@ if ( ( ARCH_ARM AND NOT ARCH_AARCH64 ) OR ARCH_I386) set (ARCH_32 1) message (WARNING "Support for 32bit platforms is highly experimental") endif () +if (CMAKE_SYSTEM MATCHES "FreeBSD") + set (ARCH_FREEBSD 1) +endif () + +if (ARCH_FREEBSD) + set (PLATFORM_EXTRA_CXX_FLAG "-DCLOCK_MONOTONIC_COARSE=CLOCK_MONOTONIC_FAST") +endif () set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wall") # -Werror is also added inside directories with our own code. set (CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS} -Wnon-virtual-dtor") @@ -154,7 +158,7 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS} -fn set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 ${CMAKE_C_FLAGS_ADD}") set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline ${CMAKE_C_FLAGS_ADD}") -if (MAKE_STATIC_LIBRARIES AND NOT APPLE AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM MATCHES "FreeBSD")) +if (MAKE_STATIC_LIBRARIES AND NOT APPLE AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND ARCH_FREEBSD)) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif () diff --git a/cmake/find_execinfo.cmake b/cmake/find_execinfo.cmake index 2e5f589170d..6d7428a166f 100644 --- a/cmake/find_execinfo.cmake +++ b/cmake/find_execinfo.cmake @@ -1,4 +1,4 @@ -if (CMAKE_SYSTEM MATCHES "FreeBSD") +if (ARCH_FREEBSD) find_library (EXECINFO_LIBRARY execinfo) message (STATUS "Using execinfo: ${EXECINFO_LIBRARY}") else () diff --git a/cmake/find_llvm.cmake b/cmake/find_llvm.cmake index 4edb441f028..8945bff451e 100644 --- a/cmake/find_llvm.cmake +++ b/cmake/find_llvm.cmake @@ -15,7 +15,7 @@ if (USE_EMBEDDED_COMPILER) # llvm_map_components_to_libraries - Maps LLVM used components to required libraries. # Usage: llvm_map_components_to_libraries(REQUIRED_LLVM_LIBRARIES core jit interpreter native ...) - if (CMAKE_SYSTEM MATCHES "FreeBSD") + if (ARCH_FREEBSD) set(LLVM_VERSION_POSTFIX "50" CACHE INTERNAL "") else() set(LLVM_VERSION_POSTFIX "-5.0" CACHE INTERNAL "") diff --git a/cmake/find_rdkafka.cmake b/cmake/find_rdkafka.cmake index adcc24ff2df..c662a73cb37 100644 --- a/cmake/find_rdkafka.cmake +++ b/cmake/find_rdkafka.cmake @@ -13,12 +13,17 @@ endif () if (NOT USE_INTERNAL_RDKAFKA_LIBRARY) find_library (RDKAFKA_LIB rdkafka) find_path (RDKAFKA_INCLUDE_DIR NAMES librdkafka/rdkafka.h PATHS ${RDKAFKA_INCLUDE_PATHS}) - find_library (SASL2_LIBRARY sasl2) + if (USE_STATIC_LIBRARIES AND NOT ARCH_FREEBSD) + find_library (SASL2_LIBRARY sasl2) + endif () endif () if (RDKAFKA_LIB AND RDKAFKA_INCLUDE_DIR) set (USE_RDKAFKA 1) - set (RDKAFKA_LIBRARY ${RDKAFKA_LIB} ${OPENSSL_LIBRARIES} ${SASL2_LIBRARY}) + set (RDKAFKA_LIBRARY ${RDKAFKA_LIB} ${OPENSSL_LIBRARIES}) + if (SASL2_LIBRARY) + list (APPEND RDKAFKA_LIBRARY ${SASL2_LIBRARY}) + endif () elseif (NOT MISSING_INTERNAL_RDKAFKA_LIBRARY) set (USE_INTERNAL_RDKAFKA_LIBRARY 1) set (RDKAFKA_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/librdkafka/src") diff --git a/cmake/find_zlib.cmake b/cmake/find_zlib.cmake index 806ab5d0b30..bafb1bb75b8 100644 --- a/cmake/find_zlib.cmake +++ b/cmake/find_zlib.cmake @@ -8,7 +8,7 @@ if (NOT ZLIB_FOUND) set (USE_INTERNAL_ZLIB_LIBRARY 1) set (ZLIB_COMPAT 1) # for zlib-ng, also enables WITH_GZFILEOP set (WITH_NATIVE_INSTRUCTIONS ${ARCHNATIVE}) - if (CMAKE_SYSTEM MATCHES "FreeBSD" OR ARCH_I386) + if (ARCH_FREEBSD OR ARCH_I386) set (WITH_OPTIM 0 CACHE INTERNAL "") # Bug in assembler endif () if (ARCH_AARCH64) diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt index 01cdb8b047f..c5eedaadc30 100644 --- a/dbms/CMakeLists.txt +++ b/dbms/CMakeLists.txt @@ -80,7 +80,7 @@ list (APPEND dbms_headers list (APPEND dbms_sources src/TableFunctions/TableFunctionFactory.cpp) list (APPEND dbms_headers src/TableFunctions/ITableFunction.h src/TableFunctions/TableFunctionFactory.h) -if (APPLE OR CMAKE_SYSTEM MATCHES "FreeBSD") +if (APPLE OR ARCH_FREEBSD) list(REMOVE_ITEM clickhouse_common_io_headers src/Common/AIO.h src/IO/WriteBufferAIO.h diff --git a/dbms/src/IO/tests/CMakeLists.txt b/dbms/src/IO/tests/CMakeLists.txt index c45675107d4..39798d9b55b 100644 --- a/dbms/src/IO/tests/CMakeLists.txt +++ b/dbms/src/IO/tests/CMakeLists.txt @@ -63,7 +63,7 @@ add_check (hashing_read_buffer) add_executable (io_operators operators.cpp ${SRCS}) target_link_libraries (io_operators clickhouse_common_io) -if (NOT APPLE AND NOT CMAKE_SYSTEM MATCHES "FreeBSD") +if (NOT APPLE AND NOT ARCH_FREEBSD) add_executable(write_buffer_aio write_buffer_aio.cpp) target_link_libraries (write_buffer_aio clickhouse_common_io ${Boost_FILESYSTEM_LIBRARY}) diff --git a/dbms/src/Interpreters/CMakeLists.txt b/dbms/src/Interpreters/CMakeLists.txt index 96b93c44868..3dea20ff290 100644 --- a/dbms/src/Interpreters/CMakeLists.txt +++ b/dbms/src/Interpreters/CMakeLists.txt @@ -1,5 +1,5 @@ -if (CMAKE_SYSTEM MATCHES "FreeBSD") +if (ARCH_FREEBSD) set (PATH_SHARE "/usr/local/share" CACHE STRING "") else () set (PATH_SHARE "/usr/share" CACHE STRING "") diff --git a/libs/libcommon/cmake/find_gperftools.cmake b/libs/libcommon/cmake/find_gperftools.cmake index 479c9b80b01..b9fcc40c0c6 100644 --- a/libs/libcommon/cmake/find_gperftools.cmake +++ b/libs/libcommon/cmake/find_gperftools.cmake @@ -1,10 +1,10 @@ -if (CMAKE_SYSTEM MATCHES "FreeBSD" OR ARCH_32) +if (ARCH_FREEBSD OR ARCH_32) option (USE_INTERNAL_GPERFTOOLS_LIBRARY "Set to FALSE to use system gperftools (tcmalloc) library instead of bundled" OFF) else () option (USE_INTERNAL_GPERFTOOLS_LIBRARY "Set to FALSE to use system gperftools (tcmalloc) library instead of bundled" ${NOT_UNBUNDLED}) endif () -if (CMAKE_SYSTEM MATCHES "FreeBSD") +if (ARCH_FREEBSD) option (ENABLE_TCMALLOC "Set to TRUE to enable tcmalloc" OFF) else () option (ENABLE_TCMALLOC "Set to TRUE to enable tcmalloc" ON) @@ -18,7 +18,7 @@ if (ENABLE_TCMALLOC) find_package (Gperftools) endif () - if (NOT (GPERFTOOLS_FOUND AND GPERFTOOLS_INCLUDE_DIR AND GPERFTOOLS_TCMALLOC_MINIMAL) AND NOT (CMAKE_SYSTEM MATCHES "FreeBSD" OR ARCH_32)) + if (NOT (GPERFTOOLS_FOUND AND GPERFTOOLS_INCLUDE_DIR AND GPERFTOOLS_TCMALLOC_MINIMAL) AND NOT (ARCH_FREEBSD OR ARCH_32)) set (USE_INTERNAL_GPERFTOOLS_LIBRARY 1) set (GPERFTOOLS_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libtcmalloc/include") set (GPERFTOOLS_TCMALLOC_MINIMAL tcmalloc_minimal_internal) diff --git a/utils/iotest/CMakeLists.txt b/utils/iotest/CMakeLists.txt index 2a307d0ba66..c41ba0303ec 100644 --- a/utils/iotest/CMakeLists.txt +++ b/utils/iotest/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries (iotest clickhouse_common_io) add_executable (iotest_nonblock iotest_nonblock.cpp ${SRCS}) target_link_libraries (iotest_nonblock clickhouse_common_io) -if (NOT APPLE AND NOT CMAKE_SYSTEM MATCHES "FreeBSD") +if (NOT APPLE AND NOT ARCH_FREEBSD) add_executable (iotest_aio iotest_aio.cpp ${SRCS}) target_link_libraries (iotest_aio clickhouse_common_io) endif()