From 0b890ed1ac926710fdb4cbde5a8af9e18d8ebf7d Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 9 Jan 2021 19:18:04 -0500 Subject: [PATCH] [client] add support for compiling with AddressSanitizer --- client/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index f60d7e18..19c392d9 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -27,6 +27,9 @@ add_feature_info(ENABLE_CB_X11 ENABLE_CB_X11 "X11 Clipboard Integration.") option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON) add_feature_info(ENABLE_BACKTRACE ENABLE_BACKTRACE "Backtrace support.") +option(ENABLE_ASAN "Build with AddressSanitizer" OFF) +add_feature_info(ENABLE_ASAN ENABLE_ASAN "AddressSanitizer support.") + add_compile_options( "-Wall" "-Werror" @@ -40,6 +43,11 @@ add_compile_options( set(EXE_FLAGS "-Wl,--gc-sections -z noexecstack") set(CMAKE_C_STANDARD 11) +if(ENABLE_ASAN) + add_compile_options("-fno-omit-frame-pointer" "-fsanitize=address") + set(EXE_FLAGS "${EXE_FLAGS} -fno-omit-frame-pointer -fsanitize=address") +endif() + find_package(PkgConfig) pkg_check_modules(PKGCONFIG REQUIRED sdl2