summaryrefslogtreecommitdiff
path: root/cmake/jemalloc.cmake
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-11-28 22:39:22 +0100
committerSergei Golubchik <serg@mariadb.org>2014-12-04 10:41:52 +0100
commit1bd1c29ea0ec51d2efefcadbc1ca217aff9f7610 (patch)
tree9f3032f80d75e7705f36a9963b322c7151e3a645 /cmake/jemalloc.cmake
parent0438f1254090f65290b3d58a7c2722d1c5311afd (diff)
downloadmariadb-git-1bd1c29ea0ec51d2efefcadbc1ca217aff9f7610.tar.gz
MDEV-6895 switch to dynamic libjemalloc.so
Diffstat (limited to 'cmake/jemalloc.cmake')
-rw-r--r--cmake/jemalloc.cmake39
1 files changed, 24 insertions, 15 deletions
diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake
index 876688f02f6..05402668c7d 100644
--- a/cmake/jemalloc.cmake
+++ b/cmake/jemalloc.cmake
@@ -1,7 +1,21 @@
INCLUDE (CheckLibraryExists)
SET(WITH_JEMALLOC auto CACHE STRING
- "Build with jemalloc. Possible values are 'yes', 'no', 'auto'")
+ "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()
MACRO (CHECK_JEMALLOC)
# compatibility with old WITH_JEMALLOC values
@@ -12,22 +26,17 @@ MACRO (CHECK_JEMALLOC)
SET(WITH_JEMALLOC "yes")
ENDIF()
- IF(WITH_JEMALLOC STREQUAL "yes" OR WITH_JEMALLOC STREQUAL "auto" OR
- WITH_JEMALLOC STREQUAL "static")
-
- IF(WITH_JEMALLOC STREQUAL "static")
- SET(libname jemalloc_pic)
- SET(CMAKE_REQUIRED_LIBRARIES pthread dl m)
- SET(what bundled)
- ELSE()
- SET(libname jemalloc)
- SET(what system)
- ENDIF()
+ IF (WITH_JEMALLOC STREQUAL "yes" OR WITH_JEMALLOC STREQUAL "auto")
+ JEMALLOC_TRY_DYNAMIC()
+ ENDIF()
- CHECK_LIBRARY_EXISTS(${libname} malloc_stats_print "" HAVE_JEMALLOC)
- SET(CMAKE_REQUIRED_LIBRARIES)
+ IF (WITH_JEMALLOC STREQUAL "static" OR WITH_JEMALLOC STREQUAL "auto"
+ AND NOT HAVE_DYNAMIC_JEMALLOC)
+ JEMALLOC_TRY_STATIC()
+ ENDIF()
- IF (HAVE_JEMALLOC)
+ IF (libname)
+ IF (HAVE_DYNAMIC_JEMALLOC OR HAVE_STATIC_JEMALLOC)
SET(LIBJEMALLOC ${libname})
SET(MALLOC_LIBRARY "${what} jemalloc")
ELSEIF (NOT WITH_JEMALLOC STREQUAL "auto")