Add support for building with JEMALLOC

This commit is contained in:
NepDisk 2026-04-28 11:40:17 -04:00
parent ea6105a007
commit 52d31ee6b5

View file

@ -182,6 +182,9 @@ set(SRB2_CONFIG_STD23 OFF CACHE BOOL
set(SRB2_CONFIG_COMPILEAPPIMAGE OFF CACHE BOOL
"Compiles the game then attempts turning it into an appimage.")
set(SRB2_CONFIG_JEMALLOC OFF CACHE BOOL
"Links jemalloc Allocator to replace GLibc malloc.")
if(SRB2_CONFIG_COMPILEAPPIMAGE AND "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
message("-- Generating Appimage at build time.")
add_custom_command(
@ -204,6 +207,18 @@ else()
set_property(TARGET BLANKART PROPERTY CXX_STANDARD 17)
endif()
# Thanks https://stackoverflow.com/a/63320046
if(SRB2_CONFIG_JEMALLOC)
message("-- Using JEMALLOC.")
find_package(PkgConfig REQUIRED)
pkg_check_modules(JEMALLOC jemalloc)
pkg_search_module(JEMALLOC REQUIRED jemalloc)
include_directories(${JEMALLOC_INCLUDE_DIRS})
target_link_libraries(BLANKART PRIVATE ${JEMALLOC_LIBRARIES})
endif()
### Configuration
set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
"Compile a development build of SRB2Kart.")