if(ALLOCATOR)
if(${ALLOCATOR} MATCHES "tcmalloc(_minimal)?")
find_package(gperftools 2.6.2 REQUIRED)
+ set(ALLOC_LIBS gperftools::${ALLOCATOR})
set(HAVE_LIBTCMALLOC ON)
elseif(${ALLOCATOR} STREQUAL "jemalloc")
find_package(JeMalloc REQUIRED)
+ set(ALLOC_LIBS JeMalloc::JeMalloc)
set(HAVE_JEMALLOC 1)
elseif(NOT ALLOCATOR STREQUAL "libc")
message(FATAL_ERROR "Unsupported allocator selected: ${ALLOCATOR}")
endif()
if(gperftools_FOUND)
set(ALLOCATOR tcmalloc)
+ set(ALLOC_LIBS gperftools::tcmalloc)
elseif(JeMalloc_FOUND)
set(ALLOCATOR jemalloc)
+ set(ALLOC_LIBS JeMalloc::JeMalloc)
else()
if(NOT FREEBSD)
# FreeBSD already has jemalloc as its default allocator
set(ALLOCATOR "libc")
endif(gperftools_FOUND)
endif(ALLOCATOR)
+if(NOT ALLOCATOR STREQUAL "libc")
+ add_compile_options(
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
+endif()
# Mingw generates incorrect entry points when using "-pie".
if(WIN32 OR (HAVE_LIBTCMALLOC AND WITH_STATIC_LIBSTDCXX))
add_subdirectory(java)
endif()
-# sort out which allocator to use
-if(ALLOCATOR STREQUAL "tcmalloc")
- set(ALLOC_LIBS gperftools::tcmalloc)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
-elseif(ALLOCATOR STREQUAL "tcmalloc_minimal")
- set(ALLOC_LIBS gperftools::tcmalloc_minimal)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
-elseif(ALLOCATOR STREQUAL "jemalloc")
- set(ALLOC_LIBS JeMalloc::JeMalloc)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
-endif()
-
if (WITH_BLKIN)
add_subdirectory(blkin/blkin-lib)
endif(WITH_BLKIN)