diff options
Diffstat (limited to 'cmake/jemalloc.cmake')
-rw-r--r-- | cmake/jemalloc.cmake | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake index 5cb9c493a20..bc6bf60781d 100644 --- a/cmake/jemalloc.cmake +++ b/cmake/jemalloc.cmake @@ -15,13 +15,20 @@ MACRO (USE_BUNDLED_JEMALLOC) IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT APPLE) # see the comment in CMakeLists.txt LIST(APPEND JEMALLOC_CONFIGURE_OPTS --enable-debug) ENDIF() + + IF(CMAKE_GENERATOR MATCHES "Makefiles") + SET(MAKE_COMMAND ${CMAKE_MAKE_PROGRAM}) + ELSE() # Xcode/Ninja generators + SET(MAKE_COMMAND make) + ENDIF() + ExternalProject_Add(jemalloc PREFIX extra/jemalloc SOURCE_DIR ${SOURCE_DIR} BINARY_DIR ${BINARY_DIR} STAMP_DIR ${BINARY_DIR} CONFIGURE_COMMAND "${SOURCE_DIR}/configure" ${JEMALLOC_CONFIGURE_OPTS} - BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} "build_lib_static" + BUILD_COMMAND ${MAKE_COMMAND} "build_lib_static" INSTALL_COMMAND "" ) ADD_LIBRARY(libjemalloc STATIC IMPORTED) @@ -29,13 +36,19 @@ MACRO (USE_BUNDLED_JEMALLOC) ADD_DEPENDENCIES(libjemalloc jemalloc) ENDMACRO() -SET(WITH_JEMALLOC "yes" CACHE STRING +IF(CMAKE_SYSTEM_NAME MATCHES "Linux" OR APPLE) + # Linux and OSX are the only systems where bundled jemalloc can be built without problems, + # as they both have GNU make and jemalloc actually compiles. + # Also, BSDs use jemalloc as malloc already + SET(WITH_JEMALLOC_DEFAULT "yes") +ELSE() + SET(WITH_JEMALLOC_DEFAULT "no") +ENDIF() + +SET(WITH_JEMALLOC ${WITH_JEMALLOC_DEFAULT} CACHE STRING "Which jemalloc to use (possible values are 'no', 'bundled', 'system', 'yes' (system if possible, otherwise bundled)") MACRO (CHECK_JEMALLOC) - IF(WIN32) - SET(WITH_JEMALLOC "no") - ENDIF() IF(WITH_JEMALLOC STREQUAL "system" OR WITH_JEMALLOC STREQUAL "yes") CHECK_LIBRARY_EXISTS(jemalloc malloc_stats_print "" HAVE_JEMALLOC) IF (HAVE_JEMALLOC) |