Build: Add -DASAN option to build with AddressSanitizer support

Use this option only for debugging purposes.
This commit is contained in:
Peter Keresztes Schmidt 2021-02-08 23:07:21 +01:00
parent 825ca07561
commit 424e6e14f6
3 changed files with 37 additions and 0 deletions

View File

@ -92,6 +92,7 @@ mark_as_advanced(
option(BUILD_TEST_SUITE "Build the test suite" 0)
option(BUILD_MAN "Build man pages" 1)
option(ASAN "DEBUGGING: Build with AddressSanitizer (ASan) support" 0)
set(ZM_RUNDIR "/var/run/zm" CACHE PATH
"Location of transient process files, default: /var/run/zm")

View File

@ -1,3 +1,21 @@
target_compile_options(zm-warning-interface
INTERFACE
-Wall)
if(ASAN)
target_compile_options(zm-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=address
-fsanitize-recover=address
-fsanitize-address-use-after-scope)
target_link_options(zm-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=address
-fsanitize-recover=address
-fsanitize-address-use-after-scope)
message(STATUS "Clang: Enabled AddressSanitizer (ASan)")
endif()

View File

@ -1,3 +1,21 @@
target_compile_options(zm-warning-interface
INTERFACE
-Wall)
if(ASAN)
target_compile_options(zm-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=address
-fsanitize-recover=address
-fsanitize-address-use-after-scope)
target_link_options(zm-compile-option-interface
INTERFACE
-fno-omit-frame-pointer
-fsanitize=address
-fsanitize-recover=address
-fsanitize-address-use-after-scope)
message(STATUS "GCC: Enabled AddressSanitizer (ASan)")
endif()