1
0
mirror of https://github.com/google/leveldb.git synced 2025-04-25 14:00:27 +08:00

build(all): add sanitizer

Use sanitizers to check memory leaks
This commit is contained in:
WangTingZheng 2023-06-28 11:29:21 +08:00
parent bf015c9cdb
commit 2908cfb34c

View File

@ -22,12 +22,19 @@ if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_EXTENSIONS OFF)
endif(NOT CMAKE_CXX_STANDARD)
option(USE_SAN "Use sanitizers to check memory leaks" OFF)
if (WIN32)
set(LEVELDB_PLATFORM_NAME LEVELDB_PLATFORM_WINDOWS)
# TODO(cmumford): Make UNICODE configurable for Windows.
add_definitions(-D_UNICODE -DUNICODE)
else (WIN32)
set(LEVELDB_PLATFORM_NAME LEVELDB_PLATFORM_POSIX)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(USE_SAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif ()
endif ()
endif (WIN32)
option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON)