cmake: More options. [#METR-23701]

This commit is contained in:
Vladimir Chebotarev 2016-12-02 01:44:59 +03:00
parent 02eb36fd03
commit bcc5500f91
23 changed files with 442 additions and 379 deletions

View File

@ -8,7 +8,13 @@ insert_final_newline = true
# Matches multiple files with brace expansion notation # Matches multiple files with brace expansion notation
# Set default charset # Set default charset
[*.{c,cpp,cxx,h,hpp,hxx,py}] [*.{c,cpp,cxx,h,hpp,hxx,py,cmake}]
charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
[CMakeLists.txt]
charset = utf-8 charset = utf-8
indent_style = tab indent_style = tab
indent_size = 4 indent_size = 4

View File

@ -1,108 +1,123 @@
project (ClickHouse) project (ClickHouse)
cmake_minimum_required(VERSION 2.6) cmake_minimum_required (VERSION 2.6)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 5 # Require at least gcc 5
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
message(FATAL_ERROR "GCC version must be at least 5! For example, if GCC 5 is available under gcc-5, g++-5 names, do the following: export CC=gcc-5 CXX=g++-5; rm -rf CMakeCache.txt CMakeFiles; and re run cmake or ./release.") message (FATAL_ERROR "GCC version must be at least 5! For example, if GCC 5 is available under gcc-5, g++-5 names, do the following: export CC=gcc-5 CXX=g++-5; rm -rf CMakeCache.txt CMakeFiles; and re run cmake or ./release.")
endif() endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# require at least clang 3.8 # Require at least clang 3.8
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
message(FATAL_ERROR "Clang version must be at least 3.8!") message (FATAL_ERROR "Clang version must be at least 3.8!")
endif() endif ()
else() else ()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang 3.8+ and GCC 5+.") message (WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang 3.8+ and GCC 5+.")
endif() endif ()
if (APPLE) if (APPLE)
set(APPLE_EXTRA_CXX_FLAG "-Dexp10=__exp10") # Also needed for libc++ set (APPLE_EXTRA_CXX_FLAG "-Dexp10=__exp10") # Also needed for libc++
endif() endif ()
# отключаем варнинг о том, что в каждой директории должен быть CMakeLists.txt
cmake_policy(SET CMP0014 OLD)
cmake_policy(SET CMP0014 OLD) # Ignore warning about CMakeLists.txt in each directory
cmake_policy(SET CMP0012 NEW) # Don't dereference TRUE and FALSE cmake_policy(SET CMP0012 NEW) # Don't dereference TRUE and FALSE
IF(NOT CMAKE_BUILD_TYPE) if (NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE is not set, set to default = RELWITHDEBINFO") message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = RELWITHDEBINFO")
SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO") set (CMAKE_BUILD_TYPE "RELWITHDEBINFO")
ENDIF() endif ()
MESSAGE( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} ) message (STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
# ASan - build type with address sanitizer # ASan - build type with address sanitizer
# UBSan - build type with undefined behaviour sanitizer # UBSan - build type with undefined behaviour sanitizer
# TSan is not supported due to false positive errors in libstdc++ and necessity to rebuild libstdc++ with TSan # TSan is not supported due to false positive errors in libstdc++ and necessity to rebuild libstdc++ with TSan
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Debug;Release;MinSizeRel;ASan;UBSan" CACHE STRING "" FORCE) set (CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Debug;Release;MinSizeRel;ASan;UBSan" CACHE STRING "" FORCE)
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)") if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
SET(AARCH64 1) set (AARCH64 1)
ENDIF() endif ()
IF (NOT AARCH64) if (NOT AARCH64)
SET(MACHINE_FLAGS "-msse4 -mpopcnt") set (MACHINE_FLAGS "-msse4 -mpopcnt")
ENDIF() endif ()
SET(COMMON_WARNING_FLAGS "-Wall -Werror") set (COMMON_WARNING_FLAGS "-Wall -Werror")
SET(CXX_WARNING_FLAGS "-Wnon-virtual-dtor -Wold-style-cast") set (CXX_WARNING_FLAGS "-Wnon-virtual-dtor -Wold-style-cast")
set (ENABLE_CXX11_ABI TRUE CACHE BOOL "Enables C++11 ABI")
set (TEST_COVERAGE FALSE CACHE BOOL "Enables flags for test coverage")
set (ENABLE_TESTS TRUE CACHE BOOL "Enables tests")
set (USE_STATIC_LIBRARIES TRUE CACHE BOOL "Set to FALSE to use shared libraries")
if (NOT $ENV{USE_STATIC_LIBRARIES})
set (USE_STATIC_LIBRARIES FALSE)
endif ()
set (GLIBC_COMPATIBILITY FALSE CACHE BOOL "Set to TRUE to enable compatibility with older glibc libraries") set (GLIBC_COMPATIBILITY FALSE CACHE BOOL "Set to TRUE to enable compatibility with older glibc libraries")
if ($ENV{GLIBC_COMPATIBILITY}) if ($ENV{GLIBC_COMPATIBILITY})
set (GLIBC_COMPATIBILITY TRUE) set (GLIBC_COMPATIBILITY TRUE)
endif() endif ()
set (ENABLE_MONGODB TRUE CACHE BOOL "Set to TRUE to enable MongoDB support as source for external dictionaries")
if (NOT $ENV{ENABLE_MONGODB})
set (ENABLE_MONGODB FALSE)
endif ()
set (ENABLE_LIBTCMALLOC TRUE CACHE BOOL "Set to TRUE to enable libtcmalloc.")
if (NOT $ENV{ENABLE_LIBTCMALLOC})
set (ENABLE_LIBTCMALLOC FALSE)
endif ()
set (DEBUG_LIBTCMALLOC FALSE CACHE BOOL "Set to TRUE to use debug version of libtcmalloc.")
if ($ENV{DEBUG_LIBTCMALLOC})
set (ENABLE_LIBTCMALLOC TRUE)
endif ()
if (GLIBC_COMPATIBILITY) if (GLIBC_COMPATIBILITY)
SET(GLIBC_COMPATIBILITY_COMPILE_FLAGS "-include ${ClickHouse_SOURCE_DIR}/libs/libcommon/include/common/glibc_compatibility.h") set (GLIBC_COMPATIBILITY_COMPILE_FLAGS "-include ${ClickHouse_SOURCE_DIR}/libs/libcommon/include/common/glibc_compatibility.h")
SET(GLIBC_COMPATIBILITY_LINK_FLAGS "-Wl,--wrap=memcpy") set (GLIBC_COMPATIBILITY_LINK_FLAGS "-Wl,--wrap=memcpy")
endif() endif ()
if (DISABLE_CXX11_ABI) if (NOT ENABLE_CXX11_ABI)
SET(CXX11_ABI "-D_GLIBCXX_USE_CXX11_ABI=0") set (CXX11_ABI "-D_GLIBCXX_USE_CXX11_ABI=0")
endif() endif ()
SET(CMAKE_BUILD_COLOR_MAKEFILE ON) set (CMAKE_BUILD_COLOR_MAKEFILE ON)
SET(CMAKE_CXX_FLAGS "-std=gnu++1y ${APPLE_EXTRA_CXX_FLAG} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS} ${CXX11_ABI}") set (CMAKE_CXX_FLAGS "-std=gnu++1y ${APPLE_EXTRA_CXX_FLAG} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS} ${CXX11_ABI}")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g") set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline") set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline")
SET(CMAKE_C_FLAGS "-fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS} ${CXX11_ABI}") set (CMAKE_C_FLAGS "-fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS} ${CXX11_ABI}")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") set (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g") set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline") set (CMAKE_C_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline")
if (NOT APPLE) if (NOT APPLE)
SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${GLIBC_COMPATIBILITY_LINK_FLAGS} ${CXX11_ABI}") set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${GLIBC_COMPATIBILITY_LINK_FLAGS} ${CXX11_ABI}")
endif() endif()
# -fuse-ld=gold - fix linkage for gcc-5.4, gcc-6.1 # -fuse-ld=gold - fix linkage for gcc-5.4, gcc-6.1
# see more in http://stackoverflow.com/questions/37603238/fsanitize-not-using-gold-linker-in-gcc-6-1 # See more in http://stackoverflow.com/questions/37603238/fsanitize-not-using-gold-linker-in-gcc-6-1
SET(CMAKE_CXX_FLAGS_ASAN "-O3 -g -fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold ${CXX11_ABI}") set (CMAKE_CXX_FLAGS_ASAN "-O3 -g -fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold ${CXX11_ABI}")
SET(CMAKE_CXX_FLAGS_UBSAN "-O3 -g -fsanitize=undefined -fno-omit-frame-pointer ${CXX11_ABI}") set (CMAKE_CXX_FLAGS_UBSAN "-O3 -g -fsanitize=undefined -fno-omit-frame-pointer ${CXX11_ABI}")
SET(CMAKE_C_FLAGS_ASAN "-O3 -g -fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold ${CXX11_ABI}") set (CMAKE_C_FLAGS_ASAN "-O3 -g -fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold ${CXX11_ABI}")
SET(CMAKE_C_FLAGS_UBSAN "-O3 -g -fsanitize=undefined -fno-omit-frame-pointer ${CXX11_ABI}") set (CMAKE_C_FLAGS_UBSAN "-O3 -g -fsanitize=undefined -fno-omit-frame-pointer ${CXX11_ABI}")
# Флаги для test coverage # Flags for test coverage
IF (TEST_COVERAGE) if (TEST_COVERAGE)
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage -fPIC -DIS_DEBUG ${CXX11_ABI}") set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage -fPIC -DIS_DEBUG ${CXX11_ABI}")
ENDIF(TEST_COVERAGE) endif (TEST_COVERAGE)
# Собирать тесты? # Run tests with "make check"
IF (NOT DEFINED TESTS) if (ENABLE_TESTS)
MESSAGE(STATUS "Tests are enabled") message (STATUS "Tests are enabled")
SET(TESTS YES) include (add.test.cmake)
ENDIF() endif (ENABLE_TESTS)
# тесты запускать с помощью "make check" # Installation prefix
IF(TESTS) set (CMAKE_INSTALL_PREFIX /usr)
INCLUDE(add.test.cmake)
ENDIF(TESTS)
# Префикс для установки
SET(CMAKE_INSTALL_PREFIX /usr)
include_directories (${ClickHouse_SOURCE_DIR}/contrib/libcityhash/include/) include_directories (${ClickHouse_SOURCE_DIR}/contrib/libcityhash/include/)
include_directories (${ClickHouse_SOURCE_DIR}/contrib/liblz4/include/) include_directories (${ClickHouse_SOURCE_DIR}/contrib/liblz4/include/)
@ -145,11 +160,11 @@ include_directories (/usr/local/lib/glib-2.0/include/)
include_directories (/usr/include/glib-2.0/) include_directories (/usr/include/glib-2.0/)
include_directories (/usr/lib64/glib-2.0/include/) include_directories (/usr/lib64/glib-2.0/include/)
IF (AARCH64) if (AARCH64)
include_directories (/usr/lib/aarch64-linux-gnu/glib-2.0/include/) include_directories (/usr/lib/aarch64-linux-gnu/glib-2.0/include/)
ELSE() else ()
include_directories (/usr/lib/x86_64-linux-gnu/glib-2.0/include/) include_directories (/usr/lib/x86_64-linux-gnu/glib-2.0/include/)
ENDIF() endif ()
include_directories (/usr/local/include/) include_directories (/usr/local/include/)
@ -160,47 +175,64 @@ link_directories (/usr/local/lib)
# 1. openssl # 1. openssl
include_directories ("/usr/local/opt/openssl/include") include_directories ("/usr/local/opt/openssl/include")
set (OPENSSL_HINTS "/usr/local/opt/openssl/lib") set (OPENSSL_HINTS "/usr/local/opt/openssl/lib")
find_library (LIBSSL libssl.a HINTS ${OPENSSL_HINTS}) if (USE_STATIC_LIBRARIES)
find_library (LIBCRYPTO libcrypto.a HINTS ${OPENSSL_HINTS}) find_library (LIBSSL libssl.a HINTS ${OPENSSL_HINTS})
find_library (LIBCRYPTO libcrypto.a HINTS ${OPENSSL_HINTS})
else ()
find_library (LIBSSL ssl HINTS ${OPENSSL_HINTS})
find_library (LIBCRYPTO crypto HINTS ${OPENSSL_HINTS})
endif ()
set (OPENSSL_LIBS ${LIBSSL} ${LIBCRYPTO}) set (OPENSSL_LIBS ${LIBSSL} ${LIBCRYPTO})
# 2. icu4c # 2. icu4c
include_directories ("/usr/local/opt/icu4c/include") include_directories ("/usr/local/opt/icu4c/include")
set (ICU_HINTS "/usr/local/opt/icu4c/lib") set (ICU_HINTS "/usr/local/opt/icu4c/lib")
find_library (ICUI18N libicui18n.a HINTS ${ICU_HINTS}) if (USE_STATIC_LIBRARIES)
find_library (ICUUC libicuuc.a HINTS ${ICU_HINTS}) find_library (ICUI18N libicui18n.a HINTS ${ICU_HINTS})
find_library (ICUDATA libicudata.a HINTS ${ICU_HINTS}) find_library (ICUUC libicuuc.a HINTS ${ICU_HINTS})
find_library (ICUDATA libicudata.a HINTS ${ICU_HINTS})
else ()
find_library (ICUI18N icui18n HINTS ${ICU_HINTS})
find_library (ICUUC icuuc HINTS ${ICU_HINTS})
find_library (ICUDATA icudata HINTS ${ICU_HINTS})
endif ()
set (ICU_LIBS ${ICUI18N} ${ICUUC} ${ICUDATA}) set (ICU_LIBS ${ICUI18N} ${ICUUC} ${ICUDATA})
# 3. boost # 3. boost
set (BOOST_HINTS "/usr/local/opt/boost/lib") set (BOOST_HINTS "/usr/local/opt/boost/lib")
find_library (BOOST_PROGRAM_OPTIONS_LIB libboost_program_options.a HINTS ${BOOST_HINTS}) if (USE_STATIC_LIBRARIES)
find_library (BOOST_SYSTEM_LIB libboost_system.a HINTS ${BOOST_HINTS}) find_library (BOOST_PROGRAM_OPTIONS_LIB libboost_program_options.a HINTS ${BOOST_HINTS})
find_library (BOOST_FILESYSTEM_LIB libboost_filesystem.a HINTS ${BOOST_HINTS}) find_library (BOOST_SYSTEM_LIB libboost_system.a HINTS ${BOOST_HINTS})
find_library (BOOST_REGEX_LIB libboost_regex.a HINTS ${BOOST_HINTS}) find_library (BOOST_FILESYSTEM_LIB libboost_filesystem.a HINTS ${BOOST_HINTS})
find_library (BOOST_THREAD_LIB libboost_thread.a HINTS ${BOOST_HINTS}) find_library (BOOST_REGEX_LIB libboost_regex.a HINTS ${BOOST_HINTS})
find_library (BOOST_THREAD_LIB libboost_thread.a HINTS ${BOOST_HINTS})
else ()
find_library (BOOST_PROGRAM_OPTIONS_LIB boost_program_options HINTS ${BOOST_HINTS})
find_library (BOOST_SYSTEM_LIB boost_system HINTS ${BOOST_HINTS})
find_library (BOOST_FILESYSTEM_LIB boost_filesystem HINTS ${BOOST_HINTS})
find_library (BOOST_REGEX_LIB boost_regex HINTS ${BOOST_HINTS})
find_library (BOOST_THREAD_LIB boost_thread HINTS ${BOOST_HINTS})
endif ()
# 4. ltdl # 4. ltdl
set (LTDL_HINTS "/usr/local/opt/libtool/lib") set (LTDL_HINTS "/usr/local/opt/libtool/lib")
find_library (LTDL_LIB libltdl.a HINTS ${LTDL_HINTS}) if (USE_STATIC_LIBRARIES)
find_library (LTDL_LIB libltdl.a HINTS ${LTDL_HINTS})
# 5. tcmalloc else ()
if(NOT DEFINED DISABLE_LIBTCMALLOC) find_library (LTDL_LIB ltdl HINTS ${LTDL_HINTS})
set(DISABLE_LIBTCMALLOC $ENV{DISABLE_LIBTCMALLOC} CACHE STRING "Don't use libtcmalloc" FORCE) endif ()
set(DEBUG_LIBTCMALLOC $ENV{DEBUG_LIBTCMALLOC} CACHE STRING "Use debug version of libtcmalloc" FORCE)
endif()
# Directory for Yandex specific files # Directory for Yandex specific files
SET(CLICKHOUSE_PRIVATE_DIR ${ClickHouse_SOURCE_DIR}/private/) set (CLICKHOUSE_PRIVATE_DIR ${ClickHouse_SOURCE_DIR}/private/)
add_subdirectory (contrib) add_subdirectory (contrib)
add_subdirectory (libs) add_subdirectory (libs)
add_subdirectory (utils) add_subdirectory (utils)
add_subdirectory (dbms) add_subdirectory (dbms)
IF (EXISTS ${CLICKHOUSE_PRIVATE_DIR}) if (EXISTS ${CLICKHOUSE_PRIVATE_DIR})
add_subdirectory (private) add_subdirectory (private)
ENDIF() endif ()
message(STATUS "C_FLAGS: =${CMAKE_C_FLAGS}") message (STATUS "C_FLAGS: =${CMAKE_C_FLAGS}")
message(STATUS "CXX_FLAGS:=${CMAKE_CXX_FLAGS}") message (STATUS "CXX_FLAGS:=${CMAKE_CXX_FLAGS}")

View File

@ -1,13 +1,13 @@
# добавляем вывод программы при ошибке теста # Adding test output on failure
enable_testing() enable_testing()
if (CMAKE_CONFIGURATION_TYPES) if (CMAKE_CONFIGURATION_TYPES)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
--force-new-ctest-process --output-on-failure --force-new-ctest-process --output-on-failure
--build-config "$<CONFIGURATION>") --build-config "$<CONFIGURATION>")
else() else ()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
--force-new-ctest-process --output-on-failure) --force-new-ctest-process --output-on-failure)
endif() endif ()
macro (add_check target) macro (add_check target)
add_test(NAME test_${target} COMMAND ${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) add_test(NAME test_${target} COMMAND ${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -1,4 +1,4 @@
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
add_subdirectory (libcityhash) add_subdirectory (libcityhash)
add_subdirectory (liblz4) add_subdirectory (liblz4)
@ -10,10 +10,10 @@ add_subdirectory (libpoco)
add_subdirectory (libre2) add_subdirectory (libre2)
add_subdirectory (libzookeeper) add_subdirectory (libzookeeper)
if (NOT DISABLE_LIBTCMALLOC) if (ENABLE_LIBTCMALLOC)
add_subdirectory (libtcmalloc) add_subdirectory (libtcmalloc)
endif() endif ()
IF (NOT AARCH64) if (NOT AARCH64)
add_subdirectory (libcpuid) add_subdirectory (libcpuid)
ENDIF() endif ()

View File

@ -1,8 +1,8 @@
include_directories (${CMAKE_CURRENT_BINARY_DIR}) include_directories (${CMAKE_CURRENT_BINARY_DIR})
IF (NOT AARCH64) # Не используется. Портировать не сложно. if (NOT AARCH64) # Not used. Pretty easy to port.
SET(SOURCES_ONLY_ON_X86_64 src/metrohash128crc.cpp) set (SOURCES_ONLY_ON_X86_64 src/metrohash128crc.cpp)
ENDIF() endif ()
add_library(metrohash add_library(metrohash
src/metrohash.h src/metrohash.h

View File

@ -101,28 +101,28 @@ option(POCO_UNBUNDLED
"Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF) "Set to OFF|ON (default is OFF) to control linking dependencies as external" OFF)
# Uncomment from next two lines to force statitc or dynamic library, default is autodetection # Uncomment from next two lines to force statitc or dynamic library, default is autodetection
if(POCO_STATIC) if (POCO_STATIC)
add_definitions( -DPOCO_STATIC -DPOCO_NO_AUTOMATIC_LIBS) add_definitions( -DPOCO_STATIC -DPOCO_NO_AUTOMATIC_LIBS)
set( LIB_MODE STATIC ) set( LIB_MODE STATIC )
message(STATUS "Building static libraries") message(STATUS "Building static libraries")
else(POCO_STATIC) else (POCO_STATIC)
set( LIB_MODE SHARED ) set( LIB_MODE SHARED )
message(STATUS "Building dynamic libraries") message(STATUS "Building dynamic libraries")
endif(POCO_STATIC) endif (POCO_STATIC)
if (ENABLE_TESTS) if (ENABLE_TESTS)
include(CTest) include(CTest)
enable_testing() enable_testing()
message(STATUS "Building with unittests & samples") message(STATUS "Building with unittests & samples")
else () else ()
message(STATUS "Building without tests & samples") message(STATUS "Building without tests & samples")
endif () endif ()
if (POCO_UNBUNDLED) if (POCO_UNBUNDLED)
add_definitions( -DPOCO_UNBUNDLED) add_definitions( -DPOCO_UNBUNDLED)
message(STATUS "Build with using external sqlite, libz, pcre, expat ...") message(STATUS "Build with using external sqlite, libz, pcre, expat ...")
else () else ()
message(STATUS "Build with using internal copy of sqlite, libz, pcre, expat, ...") message(STATUS "Build with using internal copy of sqlite, libz, pcre, expat, ...")
endif () endif ()
include(CheckTypeSize) include(CheckTypeSize)
@ -130,34 +130,34 @@ find_package(Cygwin)
# OS Detection # OS Detection
if(WIN32) if(WIN32)
add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE) add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE)
#set(SYSLIBS iphlpapi gdi32 odbc32) #set(SYSLIBS iphlpapi gdi32 odbc32)
endif(WIN32) endif(WIN32)
if (UNIX AND NOT ANDROID ) if (UNIX AND NOT ANDROID )
add_definitions( -DPOCO_OS_FAMILY_UNIX ) add_definitions( -DPOCO_OS_FAMILY_UNIX )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field -Wno-unused-local-typedef -Wno-for-loop-analysis -Wno-unknown-pragmas -Wno-unused-variable") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field -Wno-unused-local-typedef -Wno-for-loop-analysis -Wno-unknown-pragmas -Wno-unused-variable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable")
# Standard 'must be' defines # Standard 'must be' defines
if (APPLE) if (APPLE)
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64) add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64)
set(SYSLIBS dl) set(SYSLIBS dl)
else (APPLE) else (APPLE)
add_definitions(-D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_IPv6) add_definitions(-D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DPOCO_HAVE_FD_EPOLL -DPOCO_HAVE_IPv6)
set(SYSLIBS pthread dl rt) set(SYSLIBS pthread dl rt)
endif (APPLE) endif (APPLE)
endif(UNIX AND NOT ANDROID ) endif(UNIX AND NOT ANDROID )
if (CMAKE_SYSTEM MATCHES "SunOS") if (CMAKE_SYSTEM MATCHES "SunOS")
add_definitions( -DPOCO_OS_FAMILY_UNIX ) add_definitions( -DPOCO_OS_FAMILY_UNIX )
# Standard 'must be' defines # Standard 'must be' defines
add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ) add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
set(SYSLIBS pthread socket xnet nsl resolv rt dl) set(SYSLIBS pthread socket xnet nsl resolv rt dl)
endif(CMAKE_SYSTEM MATCHES "SunOS") endif(CMAKE_SYSTEM MATCHES "SunOS")
if (CMAKE_COMPILER_IS_MINGW) if (CMAKE_COMPILER_IS_MINGW)
add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8) add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8)
add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE) add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE)
endif (CMAKE_COMPILER_IS_MINGW) endif (CMAKE_COMPILER_IS_MINGW)
if (CYGWIN) if (CYGWIN)
@ -166,52 +166,52 @@ endif (CYGWIN)
# SunPro C++ # SunPro C++
if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")
add_definitions( -D_BSD_SOURCE -library=stlport4) add_definitions( -D_BSD_SOURCE -library=stlport4)
endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")
# iOS # iOS
if (IOS) if (IOS)
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES ) add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES )
endif(IOS) endif (IOS)
#Android #Android
if (ANDROID) if (ANDROID)
add_definitions( -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY ) add_definitions( -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY )
endif(ANDROID) endif (ANDROID)
# Collect the built libraries and include dirs, the will be used to create the PocoConfig.cmake file # Collect the built libraries and include dirs, the will be used to create the PocoConfig.cmake file
set(Poco_COMPONENTS "") set (Poco_COMPONENTS "")
if (ENABLE_TESTS) #if (ENABLE_TESTS)
add_subdirectory(CppUnit) # add_subdirectory (CppUnit)
#endif ()
add_subdirectory (Foundation)
if (ENABLE_XML)
add_subdirectory (XML)
list (APPEND Poco_COMPONENTS "XML")
endif () endif ()
if (ENABLE_JSON)
add_subdirectory(Foundation) add_subdirectory (JSON)
if(ENABLE_XML) list (APPEND Poco_COMPONENTS "JSON")
add_subdirectory(XML) endif ()
list(APPEND Poco_COMPONENTS "XML") if (ENABLE_MONGODB)
endif() add_subdirectory (MongoDB)
if(ENABLE_JSON) list (APPEND Poco_COMPONENTS "MongoDB")
add_subdirectory(JSON) endif ()
list(APPEND Poco_COMPONENTS "JSON") if (ENABLE_PDF)
endif() add_subdirectory (PDF)
if(ENABLE_MONGODB) list (APPEND Poco_COMPONENTS "PDF")
add_subdirectory(MongoDB)
list(APPEND Poco_COMPONENTS "MongoDB")
endif()
if(ENABLE_PDF)
add_subdirectory(PDF)
list(APPEND Poco_COMPONENTS "PDF")
endif()
if(ENABLE_UTIL)
add_subdirectory(Util)
list(APPEND Poco_COMPONENTS "Util")
endif()
if(ENABLE_NET)
add_subdirectory(Net)
list(APPEND Poco_COMPONENTS "Net")
endif() endif()
if (ENABLE_UTIL)
add_subdirectory (Util)
list (APPEND Poco_COMPONENTS "Util")
endif ()
if (ENABLE_NET)
add_subdirectory (Net)
list (APPEND Poco_COMPONENTS "Net")
endif ()
#NetSSL #NetSSL

View File

@ -1,59 +1,56 @@
SET(re2_headers set (re2_headers
./re2/tostring.cc ./re2/tostring.cc
./re2/dfa.cc ./re2/dfa.cc
./re2/prefilter.cc ./re2/prefilter.cc
./re2/compile.cc ./re2/compile.cc
./re2/regexp.cc ./re2/regexp.cc
./re2/onepass.cc ./re2/onepass.cc
./re2/prefilter_tree.cc ./re2/prefilter_tree.cc
./re2/set.cc ./re2/set.cc
./re2/filtered_re2.cc ./re2/filtered_re2.cc
./re2/perl_groups.cc ./re2/perl_groups.cc
./re2/parse.cc ./re2/parse.cc
./re2/nfa.cc ./re2/nfa.cc
./re2/bitstate.cc ./re2/bitstate.cc
./re2/simplify.cc ./re2/simplify.cc
./re2/unicode_groups.cc ./re2/unicode_groups.cc
./re2/mimics_pcre.cc ./re2/mimics_pcre.cc
./re2/re2.cc ./re2/re2.cc
./re2/prog.cc ./re2/prog.cc
./re2/unicode_casefold.cc ./re2/unicode_casefold.cc
./util/test.cc ./util/test.cc
./util/strutil.cc ./util/strutil.cc
./util/stringpiece.cc ./util/stringpiece.cc
./util/hash.cc ./util/hash.cc
./util/arena.cc ./util/arena.cc
./util/benchmark.cc ./util/benchmark.cc
./util/valgrind.cc ./util/valgrind.cc
./util/pcre.cc ./util/pcre.cc
./util/stringprintf.cc ./util/stringprintf.cc
./util/rune.cc ./util/rune.cc
./util/random.cc ./util/random.cc
./util/thread.cc ./util/thread.cc
) )
# Смысл в том, чтобы собрать две версии библиотеки - потокобезопасную (re2) и непотокобезопасную (re2_st). # Building re2 which is thread-safe and re2_st which is not.
# Библиотека re2, при выполнении регекспа, изменяет некоторое состояние - создаёт временные DFA. # re2 changes its state during matching of regular expression, e.g. creates temporary DFA.
# Для того, чтобы один объект-регексп можно было использовать одновременно из разных потоков, она использует RWLock. # It uses RWLock to process the same regular expression object from different threads.
# При этом, даже если использовать в разных потоках разные объекты re2 (созданные из одинакового регекспа), # In order to avoid redundant locks in some cases, we use not thread-safe version of the library (re2_st).
# то, не смотря на отсутствие блокировок, RWLock "вхолостую" всё-равно очень существенно тормозит. add_definitions (-DNDEBUG)
# Решение: собрать непотокобезопасную версию библиотеки и использовать разные объекты re2 в разных потоках.
add_definitions( -DNDEBUG )
add_library (re2 ${re2_headers}) add_library (re2 ${re2_headers})
add_library (re2_st ${re2_headers}) add_library (re2_st ${re2_headers})
set_target_properties(re2_st PROPERTIES COMPILE_DEFINITIONS "NO_THREADS;re2=re2_st") set_target_properties (re2_st PROPERTIES COMPILE_DEFINITIONS "NO_THREADS;re2=re2_st")
message ("Creating headers for re2_st library.") message ("Creating headers for re2_st library.")
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/re2_st) file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/re2_st)
foreach (FILENAME filtered_re2.h re2.h set.h stringpiece.h variadic_function.h) foreach (FILENAME filtered_re2.h re2.h set.h stringpiece.h variadic_function.h)
file (READ ${CMAKE_CURRENT_SOURCE_DIR}/re2/${FILENAME} CONTENT) file (READ ${CMAKE_CURRENT_SOURCE_DIR}/re2/${FILENAME} CONTENT)
string(REGEX REPLACE "using re2::RE2;" "" CONTENT "${CONTENT}") string (REGEX REPLACE "using re2::RE2;" "" CONTENT "${CONTENT}")
string(REGEX REPLACE "namespace re2" "namespace re2_st" CONTENT "${CONTENT}") string (REGEX REPLACE "namespace re2" "namespace re2_st" CONTENT "${CONTENT}")
string(REGEX REPLACE "re2::" "re2_st::" CONTENT "${CONTENT}") string (REGEX REPLACE "re2::" "re2_st::" CONTENT "${CONTENT}")
string(REGEX REPLACE "\"re2/" "\"re2_st/" CONTENT "${CONTENT}") string (REGEX REPLACE "\"re2/" "\"re2_st/" CONTENT "${CONTENT}")
string(REGEX REPLACE "(.\\*?_H)" "\\1_ST" CONTENT "${CONTENT}") string (REGEX REPLACE "(.\\*?_H)" "\\1_ST" CONTENT "${CONTENT}")
file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/re2_st/${FILENAME} "${CONTENT}") file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/re2_st/${FILENAME} "${CONTENT}")
endforeach () endforeach ()

View File

@ -1,49 +1,32 @@
include_directories(include) include_directories (include)
include_directories(/usr/include/mysql) include_directories (/usr/include/mysql)
add_subdirectory (src) add_subdirectory (src)
option(ENABLE_MONGODB "Set to TRUE to enable MongoDB support as source for external dictionaries" True)
set (DISABLE_MONGODB FALSE CACHE BOOL "Set to TRUE to disable MongoDB support as source for external dictionaries")
if (ENABLE_MONGODB) if (ENABLE_MONGODB)
set (DISABLE_MONGODB FALSE)
else()
set (DISABLE_MONGODB TRUE)
endif()
if ($ENV{DISABLE_MONGODB})
set (DISABLE_MONGODB TRUE)
endif()
if (DISABLE_MONGODB)
add_definitions(-D DISABLE_MONGODB)
else()
set (LINK_MONGOCLIENT libmongoclient.a ${OPENSSL_LIBS} ${BOOST_THREAD_LIB}) set (LINK_MONGOCLIENT libmongoclient.a ${OPENSSL_LIBS} ${BOOST_THREAD_LIB})
endif() add_definitions(-D ENABLE_MONGODB)
endif ()
if (DISABLE_LIBTCMALLOC) if (NOT ENABLE_LIBTCMALLOC)
add_definitions(-D NO_TCMALLOC) add_definitions(-D NO_TCMALLOC)
endif() endif ()
if (APPLE) if (APPLE)
set (AIO_CPP_FILES "") set (AIO_CPP_FILES "")
set (AIO_H_FILES "") set (AIO_H_FILES "")
set (APPLE_ICONV_LIB iconv) set (APPLE_ICONV_LIB iconv)
else() else()
set (AIO_H_FILES include/DB/Common/AIO.h set (AIO_H_FILES include/DB/Common/AIO.h
include/DB/IO/WriteBufferAIO.h include/DB/IO/WriteBufferAIO.h
include/DB/IO/ReadBufferAIO.h include/DB/IO/ReadBufferAIO.h)
) set (AIO_CPP_FILES
set (AIO_CPP_FILES src/IO/ReadBufferAIO.cpp
src/IO/ReadBufferAIO.cpp src/IO/WriteBufferAIO.cpp)
src/IO/WriteBufferAIO.cpp set (APPLE_ICONV_LIB "")
)
set (APPLE_ICONV_LIB "")
endif() endif()
add_library(string_utils add_library (string_utils
include/DB/Common/StringUtils.h include/DB/Common/StringUtils.h
src/Common/StringUtils.cpp) src/Common/StringUtils.cpp)
@ -978,45 +961,44 @@ add_library (dbms
) )
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# Не генерируем отладочную информацию для файлов с большим количеством инстанцирований шаблонов # Won't generate debug info for files with heavy template instantiation to achieve faster linking and lower size.
# - для более быстрой линковки и меньшего размера бинарника. set_source_files_properties(
SET_SOURCE_FILES_PROPERTIES( src/Functions/FunctionsArithmetic.cpp
src/Functions/FunctionsArithmetic.cpp src/Functions/FunctionsArray.cpp
src/Functions/FunctionsArray.cpp src/Functions/FunctionsCoding.cpp
src/Functions/FunctionsCoding.cpp src/Functions/FunctionsComparison.cpp
src/Functions/FunctionsComparison.cpp src/Functions/FunctionsConditional.cpp
src/Functions/FunctionsConditional.cpp src/Functions/FunctionsConversion.cpp
src/Functions/FunctionsConversion.cpp src/Functions/FunctionsDateTime.cpp
src/Functions/FunctionsDateTime.cpp src/Functions/FunctionsDictionaries.cpp
src/Functions/FunctionsDictionaries.cpp src/Functions/FunctionsFormatting.cpp
src/Functions/FunctionsFormatting.cpp src/Functions/FunctionsHashing.cpp
src/Functions/FunctionsHashing.cpp src/Functions/FunctionsHigherOrder.cpp
src/Functions/FunctionsHigherOrder.cpp src/Functions/FunctionsLogical.cpp
src/Functions/FunctionsLogical.cpp src/Functions/FunctionsRandom.cpp
src/Functions/FunctionsRandom.cpp src/Functions/FunctionsReinterpret.cpp
src/Functions/FunctionsReinterpret.cpp src/Functions/FunctionsRound.cpp
src/Functions/FunctionsRound.cpp src/Functions/FunctionsString.cpp
src/Functions/FunctionsString.cpp src/Functions/FunctionsStringArray.cpp
src/Functions/FunctionsStringArray.cpp src/Functions/FunctionsStringSearch.cpp
src/Functions/FunctionsStringSearch.cpp src/Functions/FunctionsURL.cpp
src/Functions/FunctionsURL.cpp src/Functions/FunctionsVisitParam.cpp
src/Functions/FunctionsVisitParam.cpp src/Functions/FunctionsMath.cpp
src/Functions/FunctionsMath.cpp src/Functions/FunctionsGeo.cpp
src/Functions/FunctionsGeo.cpp src/Functions/FunctionsMiscellaneous.cpp
src/Functions/FunctionsMiscellaneous.cpp src/Functions/FunctionsTransform.cpp
src/Functions/FunctionsTransform.cpp src/Dictionaries/FlatDictionary.cpp
src/Dictionaries/FlatDictionary.cpp src/Dictionaries/HashedDictionary.cpp
src/Dictionaries/HashedDictionary.cpp src/Dictionaries/CacheDictionary.cpp
src/Dictionaries/CacheDictionary.cpp src/Dictionaries/RangeHashedDictionary.cpp
src/Dictionaries/RangeHashedDictionary.cpp src/Dictionaries/ComplexKeyHashedDictionary.cpp
src/Dictionaries/ComplexKeyHashedDictionary.cpp src/Dictionaries/ComplexKeyCacheDictionary.cpp
src/Dictionaries/ComplexKeyCacheDictionary.cpp PROPERTIES COMPILE_FLAGS -g0)
PROPERTIES COMPILE_FLAGS -g0) endif ()
endif()
IF (NOT AARCH64) if (NOT AARCH64)
SET(LINK_LIBRARIES_ONLY_ON_X86_64 cpuid) set (LINK_LIBRARIES_ONLY_ON_X86_64 cpuid)
ENDIF() endif ()
target_link_libraries(dbms target_link_libraries(dbms
common common
@ -1028,7 +1010,7 @@ target_link_libraries(dbms
double-conversion double-conversion
${LINK_LIBRARIES_ONLY_ON_X86_64} ${LINK_LIBRARIES_ONLY_ON_X86_64}
re2 re2_st re2 re2_st
libcrypto.a ${LIBCRYPTO}
${BOOST_SYSTEM_LIB} ${BOOST_SYSTEM_LIB}
${LINK_MONGOCLIENT} ${LINK_MONGOCLIENT}
${BOOST_REGEX_LIB} ${BOOST_REGEX_LIB}

View File

@ -6,7 +6,7 @@
#include <DB/Dictionaries/MySQLDictionarySource.h> #include <DB/Dictionaries/MySQLDictionarySource.h>
#include <DB/Dictionaries/ClickHouseDictionarySource.h> #include <DB/Dictionaries/ClickHouseDictionarySource.h>
#ifndef DISABLE_MONGODB #ifdef ENABLE_MONGODB
#include <DB/Dictionaries/MongoDBDictionarySource.h> #include <DB/Dictionaries/MongoDBDictionarySource.h>
#endif #endif
@ -116,7 +116,7 @@ public:
} }
else if ("mongodb" == source_type) else if ("mongodb" == source_type)
{ {
#ifndef DISABLE_MONGODB #ifdef ENABLE_MONGODB
return std::make_unique<MongoDBDictionarySource>(dict_struct, config, config_prefix + ".mongodb", sample_block); return std::make_unique<MongoDBDictionarySource>(dict_struct, config, config_prefix + ".mongodb", sample_block);
#else #else
throw Exception{ throw Exception{

View File

@ -1,30 +1,45 @@
find_library(READLINE_LIB set (READLINE_HINTS "/usr/local/opt/readline/lib")
NAMES libreadline.a libreadline.so if (USE_STATIC_LIBRARIES)
HINTS "/usr/local/opt/readline/lib") find_library (READLINE_LIB NAMES libreadline.a HINTS ${READLINE_HINTS})
else ()
find_library (READLINE_LIB NAMES readline HINTS ${READLINE_HINTS})
endif ()
if (USE_STATIC_LIBRARIES)
find_library (EDIT_LIB NAMES libedit.a)
else ()
find_library (EDIT_LIB NAMES edit)
endif ()
if (USE_STATIC_LIBRARIES)
find_library (CURSES_LIB NAMES libcurses.a)
else ()
find_library (CURSES_LIB NAMES curses)
endif ()
if (USE_STATIC_LIBRARIES)
find_library (TERMCAP_LIB NAMES libtermcap.a termcap)
else ()
find_library (TERMCAP_LIB NAMES termcap)
endif ()
find_library(LIBEDIT_LIB if (READLINE_LIB)
NAMES libedit.a libedit.so) include_directories ("/usr/local/opt/readline/include")
add_definitions (-D USE_READLINE)
set (LINE_EDITING_LIBS ${READLINE_LIB} ${TERMCAP_LIB})
message (STATUS "Using line editing libraries: ${LINE_EDITING_LIBS}")
elseif (EDIT_LIB)
add_definitions (-D USE_LIBEDIT)
set (LINE_EDITING_LIBS ${EDIT_LIB} ${CURSES_LIB} ${TERMCAP_LIB})
message (STATUS "Using line editing libraries: ${LINE_EDITING_LIBS}")
else ()
message (STATUS "Not using any library for line editing.")
endif ()
if(READLINE_LIB) add_library (clickhouse-client Client.cpp)
include_directories("/usr/local/opt/readline/include")
add_definitions(-D USE_READLINE)
set(LINE_EDITING_LIBS ${READLINE_LIB} libtermcap.a)
message(STATUS "Using line editing libraries: ${LINE_EDITING_LIBS}")
elseif(LIBEDIT_LIB)
add_definitions(-D USE_LIBEDIT)
set(LINE_EDITING_LIBS ${LIBEDIT_LIB} libcurses.a libtermcap.a)
message(STATUS "Using line editing libraries: ${LINE_EDITING_LIBS}")
else()
message(STATUS "Not using any library for line editing.")
endif()
add_library(clickhouse-client Client.cpp)
target_link_libraries (clickhouse-client dbms ${LINE_EDITING_LIBS} ${BOOST_PROGRAM_OPTIONS_LIB}) target_link_libraries (clickhouse-client dbms ${LINE_EDITING_LIBS} ${BOOST_PROGRAM_OPTIONS_LIB})
INSTALL(FILES config.xml DESTINATION /etc/clickhouse-client COMPONENT clickhouse-client) install (FILES config.xml DESTINATION /etc/clickhouse-client COMPONENT clickhouse-client)
add_library(clickhouse-benchmark Benchmark.cpp) add_library (clickhouse-benchmark Benchmark.cpp)
target_link_libraries (clickhouse-benchmark dbms ${BOOST_PROGRAM_OPTIONS_LIB}) target_link_libraries (clickhouse-benchmark dbms ${BOOST_PROGRAM_OPTIONS_LIB})
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -24,7 +24,7 @@ brew install boost --cc=gcc-6
## Install required libraries ## Install required libraries
``` ```
brew install icu4c mysql openssl unixodbc glib libtool gettext brew install icu4c mysql openssl unixodbc glib libtool gettext homebrew/dupes/libiconv homebrew/dupes/zlib
``` ```
## Install optional libraries ## Install optional libraries

View File

@ -59,37 +59,54 @@ add_library (common
${REVISIONFILE} ${REVISIONFILE}
) )
# TESTIRT-3687 DISABLE_LIBTCMALLOC - when testing for memory leaks, disable libtcmalloc # When testing for memory leaks, disable libtcmalloc.
IF(DISABLE_LIBTCMALLOC) if (ENABLE_LIBTCMALLOC)
message(STATUS "Disabling libtcmalloc for valgrind better analysis") if (DEBUG_LIBTCMALLOC)
ELSE(DISABLE_LIBTCMALLOC) message (STATUS "Link libtcmalloc_minimal_debug for testing")
IF(DEBUG_LIBTCMALLOC) set (MALLOC_LIBRARIES libtcmalloc_minimal_debug.a)
find_library(LIBTCMALLOC_DEBUG libtcmalloc_minimal_debug.a tcmalloc_minimal_debug) # debug version of tcmalloc from package else ()
message(STATUS "Link libtcmalloc_minimal_debug for testing from ${LIBTCMALLOC_DEBUG}") message (STATUS "Link libtcmalloc_minimal")
SET(MALLOC_LIBRARIES ${LIBTCMALLOC_DEBUG}) set (MALLOC_LIBRARIES tcmalloc_minimal_internal)
ELSE(DEBUG_LIBTCMALLOC) endif ()
message(STATUS "Link libtcmalloc_minimal") else ()
SET(MALLOC_LIBRARIES tcmalloc_minimal_internal) message (STATUS "Disabling libtcmalloc for valgrind better analysis")
ENDIF(DEBUG_LIBTCMALLOC) endif ()
ENDIF(DISABLE_LIBTCMALLOC)
if (APPLE) if (APPLE)
SET(RT_LIBRARIES "apple_rt") set (RT_LIBRARIES "apple_rt")
else() else ()
SET(RT_LIBRARIES "librt.a") if (USE_STATIC_LIBRARIES)
endif() set (RT_LIBRARIES "librt.a")
else ()
set (RT_LIBRARIES "rt")
endif ()
endif ()
set (GLIB_HINTS "/usr/local/opt/glib/lib") set (GLIB_HINTS "/usr/local/opt/glib/lib")
find_library (GLIB_LIB libglib-2.0.a HINTS ${GLIB_HINTS}) if (USE_STATIC_LIBRARIES)
find_library (GLIB_LIB libglib-2.0.a HINTS ${GLIB_HINTS})
else ()
find_library (GLIB_LIB glib-2.0 HINTS ${GLIB_HINTS})
endif ()
if (APPLE) if (APPLE)
set (INTL_HINTS "/usr/local/opt/gettext/lib") set (INTL_HINTS "/usr/local/opt/gettext/lib")
find_library (INTL_LIB libintl.a HINTS ${INTL_HINTS}) if (USE_STATIC_LIBRARIES)
find_library (INTL_LIB libintl.a HINTS ${INTL_HINTS})
else ()
find_library (INTL_LIB intl HINTS ${INTL_HINTS})
endif ()
set (ICONV_HINTS "/usr/local/opt/libiconv/lib")
if (USE_STATIC_LIBRARIES)
find_library (ICONV_LIB libiconv.a HINTS ${ICONV_HINTS})
else ()
find_library (ICONV_LIB iconv HINTS ${ICONV_HINTS})
endif ()
find_library (CORE_FOUNDATION_LIB CoreFoundation) find_library (CORE_FOUNDATION_LIB CoreFoundation)
find_library (CARBON_LIB Carbon) find_library (CARBON_LIB Carbon)
set (GLIB_LIBS ${GLIB_LIB} ${INTL_LIB} libiconv.a ${CORE_FOUNDATION_LIB} ${CARBON_LIB}) set (GLIB_LIBS ${GLIB_LIB} ${INTL_LIB} ${ICONV_LIB} ${CORE_FOUNDATION_LIB} ${CARBON_LIB})
else () else (APPLE)
set (GLIB_LIBS ${GLIB_LIB}) set (GLIB_LIBS ${GLIB_LIB})
endif () endif (APPLE)
target_link_libraries ( target_link_libraries (
common common
@ -100,6 +117,6 @@ target_link_libraries (
${ICU_LIBS} ${ICU_LIBS}
${RT_LIBRARIES}) ${RT_LIBRARIES})
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (src/tests) add_subdirectory (src/tests)
ENDIF(TESTS) endif (ENABLE_TESTS)

View File

@ -27,19 +27,33 @@ add_library (mysqlxx
add_dependencies (mysqlxx common) add_dependencies (mysqlxx common)
set (MYSQL_HINTS "/usr/local/opt/mysql/lib") set (MYSQL_HINTS "/usr/local/opt/mysql/lib")
find_library (MYSQLCLIENT_LIB libmysqlclient.a HINTS ${MYSQL_HINTS}) if (USE_STATIC_LIBRARIES)
set (OUR_MYSQLCLIENT_LIB ${CMAKE_CURRENT_BINARY_DIR}/libmysqlclient.a) find_library (STATIC_MYSQLCLIENT_LIB libmysqlclient.a HINTS ${MYSQL_HINTS})
else ()
find_library (MYSQLCLIENT_LIB mysqlclient HINTS ${MYSQL_HINTS})
endif ()
target_link_libraries (mysqlxx common ${OUR_MYSQLCLIENT_LIB} ${OPENSSL_LIBS} libz.a dl) set (Z_HINTS "/usr/local/opt/zlib/lib")
if (USE_STATIC_LIBRARIES)
find_library (Z_LIB libz.a HINTS ${Z_HINTS})
else ()
find_library (Z_LIB z HINTS ${Z_HINTS})
endif ()
add_custom_command( if (USE_STATIC_LIBRARIES)
OUTPUT ${OUR_MYSQLCLIENT_LIB} set (MYSQLCLIENT_LIB ${CMAKE_CURRENT_BINARY_DIR}/libmysqlclient.a)
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/patch.sh ${MYSQLCLIENT_LIB} ${OUR_MYSQLCLIENT_LIB} target_link_libraries (mysqlxx common ${MYSQLCLIENT_LIB} ${OPENSSL_LIBS} ${Z_LIB} dl)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} add_custom_command(
COMMENT "Patching mysqlclient library.") OUTPUT ${MYSQLCLIENT_LIB}
add_custom_target(our_mysql_client DEPENDS ${OUR_MYSQLCLIENT_LIB}) COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/patch.sh ${STATIC_MYSQLCLIENT_LIB} ${MYSQLCLIENT_LIB}
add_dependencies(mysqlxx our_mysql_client) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Patching mysqlclient library.")
add_custom_target(our_mysql_client DEPENDS ${MYSQLCLIENT_LIB})
add_dependencies(mysqlxx our_mysql_client)
endif ()
if (TESTS) target_link_libraries (mysqlxx common ${MYSQLCLIENT_LIB} ${OPENSSL_LIBS} ${Z_LIB} dl)
if (ENABLE_TESTS)
add_subdirectory (src/tests) add_subdirectory (src/tests)
endif (TESTS) endif (ENABLE_TESTS)

View File

@ -1,3 +1,3 @@
IF(TESTS) if (ENABLE_TESTS)
add_subdirectory (tests) add_subdirectory (tests)
ENDIF(TESTS) endif (ENABLE_TESTS)