2014-09-12 08:41:16 +02:00
|
|
|
INCLUDE (CheckLibraryExists)
|
2013-09-09 14:02:42 +02:00
|
|
|
|
2014-09-12 08:41:16 +02:00
|
|
|
SET(WITH_JEMALLOC auto CACHE STRING
|
2014-11-28 22:39:22 +01:00
|
|
|
"Build with jemalloc. Possible values are 'yes', 'no', 'static', 'auto'")
|
|
|
|
|
2014-09-12 08:41:16 +02:00
|
|
|
MACRO (CHECK_JEMALLOC)
|
|
|
|
# compatibility with old WITH_JEMALLOC values
|
|
|
|
IF(WITH_JEMALLOC STREQUAL "bundled")
|
|
|
|
MESSAGE(FATAL_ERROR "MariaDB no longer bundles jemalloc")
|
2013-08-30 10:56:26 +02:00
|
|
|
ENDIF()
|
2014-09-12 08:41:16 +02:00
|
|
|
IF(WITH_JEMALLOC STREQUAL "system")
|
|
|
|
SET(WITH_JEMALLOC "yes")
|
2013-09-23 23:33:18 +02:00
|
|
|
ENDIF()
|
2013-09-24 19:52:51 +02:00
|
|
|
|
2014-09-18 17:00:44 +02:00
|
|
|
IF(WITH_JEMALLOC STREQUAL "yes" OR WITH_JEMALLOC STREQUAL "auto" OR
|
|
|
|
WITH_JEMALLOC STREQUAL "static")
|
|
|
|
|
|
|
|
IF(WITH_JEMALLOC STREQUAL "static")
|
|
|
|
SET(libname jemalloc_pic)
|
2020-08-02 10:30:46 +02:00
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES pthread ${CMAKE_DL_LIBS} m)
|
2014-09-18 21:54:45 +02:00
|
|
|
SET(what bundled)
|
2014-09-18 17:00:44 +02:00
|
|
|
ELSE()
|
2016-02-15 18:05:05 +01:00
|
|
|
SET(libname jemalloc c)
|
2014-09-18 21:54:45 +02:00
|
|
|
SET(what system)
|
2014-09-18 17:00:44 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2016-02-15 18:05:05 +01:00
|
|
|
FOREACH(lib ${libname})
|
|
|
|
CHECK_LIBRARY_EXISTS(${lib} malloc_stats_print "" HAVE_JEMALLOC_IN_${lib})
|
|
|
|
IF (HAVE_JEMALLOC_IN_${lib})
|
|
|
|
SET(LIBJEMALLOC ${lib})
|
|
|
|
SET(MALLOC_LIBRARY "${what} jemalloc")
|
|
|
|
BREAK()
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
2014-09-18 17:00:44 +02:00
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
2016-02-15 18:05:05 +01:00
|
|
|
IF (NOT LIBJEMALLOC AND NOT WITH_JEMALLOC STREQUAL "auto")
|
|
|
|
MESSAGE(FATAL_ERROR "jemalloc is not found")
|
2013-09-19 20:19:00 +02:00
|
|
|
ENDIF()
|
2017-08-09 21:39:18 +02:00
|
|
|
ADD_FEATURE_INFO(JEMALLOC LIBJEMALLOC "Use the JeMalloc memory allocator")
|
2013-09-19 20:19:00 +02:00
|
|
|
ENDIF()
|
2013-08-30 10:56:26 +02:00
|
|
|
ENDMACRO()
|