add MI_PADDING flag to cmake to supress use of padding in debug mode

This commit is contained in:
daan 2020-04-07 10:01:18 -07:00
parent afc4f79a69
commit 69a0846478
6 changed files with 13 additions and 9 deletions

View file

@ -14,6 +14,7 @@ option(MI_OSX_ZONE "Use malloc zone to override standard malloc on macO
option(MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanism (Unix)" OFF)
option(MI_BUILD_TESTS "Build test executables" ON)
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
option(MI_PADDING "Enable padding to detect heap block overflow (only in debug mode)" ON)
include("cmake/mimalloc-config-version.cmake")
@ -99,6 +100,11 @@ if(MI_DEBUG_FULL MATCHES "ON")
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking
endif()
if(MI_PADDING MATCHES "OFF")
message(STATUS "Disable padding of heap blocks in debug mode (MI_PADDING=OFF)")
list(APPEND mi_defines MI_PADDING=0)
endif()
if(MI_USE_CXX MATCHES "ON")
message(STATUS "Use the C++ compiler to compile (MI_USE_CXX=ON)")
set_source_files_properties(${mi_sources} PROPERTIES LANGUAGE CXX )