summaryrefslogtreecommitdiff
path: root/cmake/jemalloc.cmake
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-08-30 10:56:26 +0200
committerSergei Golubchik <sergii@pisem.net>2013-08-30 10:56:26 +0200
commitcd92bc38a7fd9442f668fbb1eed1634b04cc6d4d (patch)
tree5b913cfddbc37f980b2bcb094dd35b5166b17566 /cmake/jemalloc.cmake
parent253366e7762ef73145d3a73bf3212083522aa259 (diff)
downloadmariadb-git-cd92bc38a7fd9442f668fbb1eed1634b04cc6d4d.tar.gz
start using jemalloc
Diffstat (limited to 'cmake/jemalloc.cmake')
-rw-r--r--cmake/jemalloc.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake
new file mode 100644
index 00000000000..590ca82655b
--- /dev/null
+++ b/cmake/jemalloc.cmake
@@ -0,0 +1,33 @@
+INCLUDE(ExternalProject)
+
+MACRO (USE_BUNDLED_JEMALLOC)
+ SET(SOURCE_DIR "${CMAKE_SOURCE_DIR}/extra/jemalloc")
+ SET(BINARY_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/extra/jemalloc/build")
+ SET(LIBJEMALLOC "${BINARY_DIR}/lib/libjemalloc_pic.a")
+ SET(JEMALLOC_CONFIGURE_OPTS "CC=${CMAKE_C_COMPILER}" "--with-private-namespace=jemalloc_internal_" "--enable-cc-silence")
+ IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT APPLE) # see the comment in CMakeLists.txt
+ LIST(APPEND JEMALLOC_CONFIGURE_OPTS --enable-debug)
+ ENDIF()
+ ExternalProject_Add(jemalloc
+ PREFIX extra/jemalloc
+ SOURCE_DIR ${SOURCE_DIR}
+ BINARY_DIR ${BINARY_DIR}
+ STAMP_DIR ${SOURCE_DIR}
+ CONFIGURE_COMMAND "${SOURCE_DIR}/configure" ${JEMALLOC_CONFIGURE_OPTS}
+ BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} "build_lib_static"
+ INSTALL_COMMAND ""
+ )
+ ADD_LIBRARY(libjemalloc STATIC IMPORTED)
+ SET_TARGET_PROPERTIES(libjemalloc PROPERTIES IMPORTED_LOCATION ${LIBJEMALLOC})
+ ADD_DEPENDENCIES(libjemalloc jemalloc)
+ENDMACRO()
+
+SET(WITH_JEMALLOC "yes" CACHE STRING
+ "Which jemalloc to use (possible values are 'no', 'bundled', 'yes' (same as bundled)")
+#"Which jemalloc to use (possible values are 'no', 'bundled', 'system', 'yes' (system if possible, otherwise bundled)")
+
+MACRO (CHECK_JEMALLOC)
+ IF(WITH_JEMALLOC STREQUAL "bundled" OR WITH_JEMALLOC STREQUAL "yes")
+ USE_BUNDLED_JEMALLOC()
+ ENDIF()
+ENDMACRO()