From 05da75f1fb08719b373ba94a9faf5d5ce77d3874 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 14 Nov 2017 20:46:50 +0100 Subject: build: Add options for debug builds with sanitizer This adds three build types, DebugASan, DebugTSan and DebugLSan that enable the Address, Thread and Leak Sanitizer by setting the fsanitize flag to the compiler. This option is supported by both gcc and clang. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index f23925fe..f5836217 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,13 @@ test_and_set_c_compiler_flag_global(-fmax-errors=5) if (CMAKE_BUILD_TYPE STREQUAL "Release") test_and_set_c_compiler_flag_global(-O3) endif () +if (CMAKE_BUILD_TYPE STREQUAL "DebugASan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") +elseif (CMAKE_BUILD_TYPE STREQUAL "DebugTSan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") +elseif (CMAKE_BUILD_TYPE STREQUAL "DebugLSan") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=leak") +endif () configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-dev.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc" @ONLY) -- cgit v1.2.3