option to link with jemalloc on *nix, off by default.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 May 2011 11:16:32 +0000 (11:16 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 May 2011 11:16:32 +0000 (11:16 +0000)
CMakeLists.txt
build_files/cmake/macros.cmake

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)
index ca1dd79cd8e6020a190f01f53f0a8f99e5951ed2..8a1f6875b6fe71a0956dc45443f57034450f9275 100644 (file)
@@ -114,6 +114,9 @@ macro(SETUP_LIBDIRS)
                link_directories(${PCRE_LIBPATH})
                link_directories(${EXPAT_LIBPATH})
        endif()
+       if(WITH_MEM_JEMALLOC)
+               link_directories(${JEMALLOC_LIBPATH})
+       endif()
 
        if(WIN32 AND NOT UNIX)
                link_directories(${PTHREADS_LIBPATH})
@@ -220,6 +223,9 @@ macro(setup_liblinks
                        target_link_libraries(${target} optimized ${LCMS_LIB})
                endif()
        endif()
+       if(WITH_MEM_JEMALLOC)
+               target_link_libraries(${target} ${JEMALLOC_LIBRARY})
+       endif()
        if(WIN32 AND NOT UNIX)
                target_link_libraries(${target} ${PTHREADS_LIB})
        endif()