diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /cmake/jemalloc.cmake | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-9e4947182e0b875da38088fdd168e775f473b8ad.tar.xz mariadb-10.5-9e4947182e0b875da38088fdd168e775f473b8ad.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/jemalloc.cmake')
-rw-r--r-- | cmake/jemalloc.cmake | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake new file mode 100644 index 00000000..55369157 --- /dev/null +++ b/cmake/jemalloc.cmake @@ -0,0 +1,42 @@ +INCLUDE (CheckLibraryExists) + +SET(WITH_JEMALLOC auto CACHE STRING + "Build with jemalloc. Possible values are 'yes', 'no', 'static', 'auto'") + +MACRO (CHECK_JEMALLOC) + # compatibility with old WITH_JEMALLOC values + IF(WITH_JEMALLOC STREQUAL "bundled") + MESSAGE(FATAL_ERROR "MariaDB no longer bundles jemalloc") + ENDIF() + IF(WITH_JEMALLOC STREQUAL "system") + SET(WITH_JEMALLOC "yes") + ENDIF() + + IF(WITH_JEMALLOC STREQUAL "yes" OR WITH_JEMALLOC STREQUAL "auto" OR + WITH_JEMALLOC STREQUAL "static") + + IF(WITH_JEMALLOC STREQUAL "static") + SET(libname jemalloc_pic) + SET(CMAKE_REQUIRED_LIBRARIES pthread ${CMAKE_DL_LIBS} m) + SET(what bundled) + ELSE() + SET(libname jemalloc c) + SET(what system) + ENDIF() + + FOREACH(lib ${libname}) + CHECK_LIBRARY_EXISTS(${lib} malloc_stats_print "" HAVE_JEMALLOC_IN_${lib}) + IF (HAVE_JEMALLOC_IN_${lib}) + SET(LIBJEMALLOC ${lib}) + SET(MALLOC_LIBRARY "${what} jemalloc") + BREAK() + ENDIF() + ENDFOREACH() + SET(CMAKE_REQUIRED_LIBRARIES) + + IF (NOT LIBJEMALLOC AND NOT WITH_JEMALLOC STREQUAL "auto") + MESSAGE(FATAL_ERROR "jemalloc is not found") + ENDIF() + ADD_FEATURE_INFO(JEMALLOC LIBJEMALLOC "Use the JeMalloc memory allocator") + ENDIF() +ENDMACRO() |