mirror of
https://github.com/openstreetmap/mod_tile.git
synced 2025-07-25 15:04:30 +00:00
[Backport] Allow linking alternate memory management implementations (#454)
With new `CMake CACHE` entry `MALLOC_LIB`, supporting the following values: * `libc` (default): Use the system's implementation * `jemalloc`: Use [jemalloc](http://jemalloc.net) * `mimalloc`: Use [mimalloc](https://github.com/microsoft/mimalloc) * `tcmalloc`: Use [tcmalloc](https://github.com/google/tcmalloc) Co-authored-by: Roland Bosa <roland.bosa@gmail.com>
This commit is contained in:
@ -32,6 +32,8 @@ set(USE_CAIRO ON CACHE BOOL "Add cairo support if available (for `store_ro_compo
|
||||
set(USE_CURL ON CACHE BOOL "Add curl support if available (for `store_ro_http_proxy.c` backend)")
|
||||
set(USE_MEMCACHED ON CACHE BOOL "Add memcached support if available (for `store_memcached.c` backend)")
|
||||
set(USE_RADOS ON CACHE BOOL "Add rados support if available (for `store_rados.c` backend)")
|
||||
set(MALLOC_LIB "libc" CACHE STRING "Memory Management Library for `renderd`")
|
||||
set_property(CACHE MALLOC_LIB PROPERTY STRINGS "libc" "jemalloc" "mimalloc" "tcmalloc")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
@ -82,6 +84,21 @@ check_include_file(paths.h HAVE_PATHS_H)
|
||||
check_include_file(sys/cdefs.h HAVE_SYS_CDEFS_H)
|
||||
check_include_file(sys/loadavg.h HAVE_SYS_LOADAVG_H)
|
||||
|
||||
# Libraries
|
||||
if(NOT MALLOC_LIB STREQUAL "libc")
|
||||
message(STATUS "Using '${MALLOC_LIB}' for memory managment")
|
||||
if(MALLOC_LIB STREQUAL "jemalloc")
|
||||
# jemalloc (http://jemalloc.net)
|
||||
find_library(MALLOC_LIBRARY jemalloc REQUIRED)
|
||||
elseif(MALLOC_LIB STREQUAL "mimalloc")
|
||||
# mimalloc (https://github.com/microsoft/mimalloc)
|
||||
find_library(MALLOC_LIBRARY mimalloc REQUIRED)
|
||||
elseif(MALLOC_LIB STREQUAL "tcmalloc")
|
||||
# tcmalloc (https://github.com/google/tcmalloc)
|
||||
find_library(MALLOC_LIBRARY tcmalloc REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Set variables
|
||||
|
@ -57,6 +57,11 @@ set(STORE_LIBRARIES
|
||||
${LIBRADOS_LIBRARIES}
|
||||
)
|
||||
|
||||
if(NOT MALLOC_LIB STREQUAL "libc")
|
||||
message(STATUS "Prepending '${MALLOC_LIBRARY}' to RENDER_LIBRARIES")
|
||||
list(PREPEND RENDER_LIBRARIES ${MALLOC_LIBRARY})
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
# Installed targets
|
||||
|
Reference in New Issue
Block a user