option to link with jemalloc on *nix, off by default.
[blender-staging.git] / CMakeLists.txt
index 03f62a075632d7d55c4f07154e716bbae9e41d93..7abb6daa4dfdc11ccca812bb8ec3bd980e5b1883 100644 (file)
@@ -175,6 +175,10 @@ if(UNIX AND NOT APPLE)
 endif()
 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
 
+# disable for now, but plan to support on all platforms eventually
+option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
+mark_as_advanced(WITH_MEM_JEMALLOC)
+
 # Debug
 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
@@ -424,6 +428,15 @@ if(UNIX AND NOT APPLE)
                set(EXPAT_LIB expat)
        endif()
 
+       if(WITH_MEM_JEMALLOC)
+               set(JEMALLOC /usr)
+               set(JEMALLOC_LIBRARY ljemalloc CACHE STRING "JeMalloc library")
+               set(JEMALLOC_LIBPATH ${JEMALLOC}/lib  CACHE FILEPATH "JeMalloc library path")
+               # no use for this yet.
+               # set(JEMALLOC_INCLUDE_DIR ${JEMALLOC}/include  CACHE FILEPATH "JeMalloc include path")
+               unset(JEMALLOC)
+       endif()
+
        find_package(X11 REQUIRED)
        find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
        mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)