cmake: add SRB2_CONFIG_ASAN, enable AddressSanitizer

This commit is contained in:
James R 2023-04-22 18:35:11 -07:00
parent 5085bdfdd8
commit 9e59bd6d67
2 changed files with 5 additions and 0 deletions

View file

@ -81,6 +81,7 @@ option(SRB2_CONFIG_PACKETDROP "Compile with PACKETDROP defined." OFF)
option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
# SRB2_CONFIG_PROFILEMODE is probably superceded by some CMake setting.
option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
option(SRB2_CONFIG_ASAN "Compile with AddressSanitizer (libasan)." OFF)
set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
if(SRB2_CONFIG_ENABLE_TESTS)

View file

@ -553,6 +553,10 @@ if(SRB2_CONFIG_PROFILEMODE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(SRB2SDL2 PRIVATE -pg)
target_link_options(SRB2SDL2 PRIVATE -pg)
endif()
if(SRB2_CONFIG_ASAN)
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
endif()
add_subdirectory(audio)
add_subdirectory(core)