2019-10-13 16:06:54 +00:00
|
|
|
if (OS_LINUX AND NOT SANITIZE AND NOT ARCH_32 AND NOT ARCH_PPC64LE)
|
2019-10-05 19:25:31 +00:00
|
|
|
set(ENABLE_JEMALLOC_DEFAULT ${ENABLE_LIBRARIES})
|
2018-08-08 03:37:35 +00:00
|
|
|
else ()
|
|
|
|
set(ENABLE_JEMALLOC_DEFAULT 0)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
option (ENABLE_JEMALLOC "Set to TRUE to use jemalloc" ${ENABLE_JEMALLOC_DEFAULT})
|
2019-10-13 16:06:54 +00:00
|
|
|
if (OS_LINUX)
|
2018-08-03 16:39:04 +00:00
|
|
|
option (USE_INTERNAL_JEMALLOC_LIBRARY "Set to FALSE to use system jemalloc library instead of bundled" ${NOT_UNBUNDLED})
|
2019-06-28 18:06:09 +00:00
|
|
|
else()
|
2018-08-03 21:13:54 +00:00
|
|
|
option (USE_INTERNAL_JEMALLOC_LIBRARY "Set to FALSE to use system jemalloc library instead of bundled" OFF)
|
|
|
|
endif()
|
2017-02-28 23:49:04 +00:00
|
|
|
|
2017-01-27 20:00:02 +00:00
|
|
|
if (ENABLE_JEMALLOC)
|
2018-09-28 14:53:20 +00:00
|
|
|
if (USE_INTERNAL_JEMALLOC_LIBRARY AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/jemalloc/src/jemalloc.c")
|
|
|
|
message (WARNING "submodule contrib/jemalloc is missing. to fix try run: \n git submodule update --init --recursive")
|
|
|
|
set (USE_INTERNAL_JEMALLOC_LIBRARY 0)
|
|
|
|
set (MISSING_INTERNAL_JEMALLOC_LIBRARY 1)
|
|
|
|
endif ()
|
|
|
|
|
2018-08-03 16:39:04 +00:00
|
|
|
if (NOT USE_INTERNAL_JEMALLOC_LIBRARY)
|
2018-08-02 00:20:20 +00:00
|
|
|
find_package (JeMalloc)
|
|
|
|
endif ()
|
2017-01-27 20:00:02 +00:00
|
|
|
|
2019-10-13 16:06:54 +00:00
|
|
|
if ((NOT JEMALLOC_LIBRARIES OR NOT JEMALLOC_INCLUDE_DIR) AND NOT MISSING_INTERNAL_JEMALLOC_LIBRARY )
|
2018-08-03 16:39:04 +00:00
|
|
|
set (JEMALLOC_LIBRARIES "jemalloc")
|
2018-11-21 19:20:27 +00:00
|
|
|
set (JEMALLOC_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/jemalloc-cmake/include" "${ClickHouse_SOURCE_DIR}/contrib/jemalloc-cmake/include_linux_x86_64")
|
2018-08-03 16:39:04 +00:00
|
|
|
set (USE_INTERNAL_JEMALLOC_LIBRARY 1)
|
|
|
|
endif ()
|
|
|
|
|
2018-08-02 00:20:20 +00:00
|
|
|
if (JEMALLOC_LIBRARIES)
|
2017-04-01 07:20:54 +00:00
|
|
|
set (USE_JEMALLOC 1)
|
2019-06-28 18:06:09 +00:00
|
|
|
elseif (NOT MISSING_INTERNAL_JEMALLOC_LIBRARY)
|
2018-08-02 00:20:20 +00:00
|
|
|
message (FATAL_ERROR "ENABLE_JEMALLOC is set to true, but library was not found")
|
2017-04-01 07:20:54 +00:00
|
|
|
endif ()
|
2018-08-02 00:20:20 +00:00
|
|
|
|
2018-08-08 03:37:35 +00:00
|
|
|
if (SANITIZE)
|
|
|
|
message (FATAL_ERROR "ENABLE_JEMALLOC is set to true, but it cannot be used with sanitizers")
|
|
|
|
endif ()
|
|
|
|
|
2018-11-01 14:07:14 +00:00
|
|
|
message (STATUS "Using jemalloc=${USE_JEMALLOC}: ${JEMALLOC_INCLUDE_DIR} : ${JEMALLOC_LIBRARIES}")
|
2017-01-27 20:00:02 +00:00
|
|
|
endif ()
|