From e6565ef076bb0f1b65ef1f7dc0db901acc42689f Mon Sep 17 00:00:00 2001 From: FritzFlorian Date: Tue, 26 Mar 2019 15:15:59 +0100 Subject: [PATCH] Add AddressSanitizer Script. --- CMakeLists.txt | 1 + cmake/SetupAddressSanitizer.cmake | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 cmake/SetupAddressSanitizer.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 92b9eca..513e8a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ include(cmake/DisabelInSource.cmake) include(cmake/SetupOptimizationLevel.cmake) include(cmake/SetupThreadingSupport.cmake) include(cmake/SetupThreadSanitizer.cmake) +include(cmake/SetupAddressSanitizer.cmake) # make our internal cmake script collection avaliable in the build process. list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/cmake") diff --git a/cmake/SetupAddressSanitizer.cmake b/cmake/SetupAddressSanitizer.cmake new file mode 100644 index 0000000..f2422a7 --- /dev/null +++ b/cmake/SetupAddressSanitizer.cmake @@ -0,0 +1,10 @@ +# Optionally compile with thread sanitizer enabled to find concurrency bugs +# https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual + +# Add optional sanitizer, off by default +option(ADDRESS_SANITIZER "Add address sanitizer" OFF) +if(ADDRESS_SANITIZER) + add_compile_options(-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope -g) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") +endif() +message("-- Address Sanitizer: ${ADDRESS_SANITIZER}") -- libgit2 0.26.0