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'")
|
|
|
|
|
|
|
|
MACRO(JEMALLOC_TRY_STATIC)
|
|
|
|
SET(libname jemalloc_pic)
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES pthread dl m)
|
|
|
|
SET(what bundled)
|
|
|
|
CHECK_LIBRARY_EXISTS(${libname} malloc_stats_print "" HAVE_STATIC_JEMALLOC)
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
MACRO(JEMALLOC_TRY_DYNAMIC)
|
|
|
|
SET(libname jemalloc)
|
|
|
|
SET(what system)
|
|
|
|
CHECK_LIBRARY_EXISTS(${libname} malloc_stats_print "" HAVE_DYNAMIC_JEMALLOC)
|
|
|
|
ENDMACRO()
|
2013-08-30 10:56:26 +02:00
|
|
|
|
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-11-28 22:39:22 +01:00
|
|
|
IF (WITH_JEMALLOC STREQUAL "yes" OR WITH_JEMALLOC STREQUAL "auto")
|
|
|
|
JEMALLOC_TRY_DYNAMIC()
|
|
|
|
ENDIF()
|
2014-09-18 17:00:44 +02:00
|
|
|
|
2014-11-28 22:39:22 +01:00
|
|
|
IF (WITH_JEMALLOC STREQUAL "static" OR WITH_JEMALLOC STREQUAL "auto"
|
|
|
|
AND NOT HAVE_DYNAMIC_JEMALLOC)
|
|
|
|
JEMALLOC_TRY_STATIC()
|
|
|
|
ENDIF()
|
2014-09-18 17:00:44 +02:00
|
|
|
|
2014-11-28 22:39:22 +01:00
|
|
|
IF (libname)
|
|
|
|
IF (HAVE_DYNAMIC_JEMALLOC OR HAVE_STATIC_JEMALLOC)
|
2014-09-18 17:00:44 +02:00
|
|
|
SET(LIBJEMALLOC ${libname})
|
2014-09-18 21:54:45 +02:00
|
|
|
SET(MALLOC_LIBRARY "${what} jemalloc")
|
2014-09-18 17:00:44 +02:00
|
|
|
ELSEIF (NOT WITH_JEMALLOC STREQUAL "auto")
|
|
|
|
MESSAGE(FATAL_ERROR "${libname} is not found")
|
2013-09-19 20:19:00 +02:00
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
2013-08-30 10:56:26 +02:00
|
|
|
ENDMACRO()
|