From 0521f79fae14983b9efa4b782d3ec347a59b3e8d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 30 Mar 2021 12:06:32 -0700 Subject: build-system: make ASAN builds easier This is a bit lacking sophistication (you need to remember to make clean before rebuilding when changing this option, etc), but it works well enough for my purpuses. Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 031f6b819..5850462f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,9 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD( "We don't support building in source, please create a build folder elsewhere and remember to run git clean -xdf to remove temporary files created by CMake." ) +#Option for memory debugging +option(SUBSURFACE_ASAN_BUILD "enable memory debugging of Subsurface binary" OFF) + #Option for profiling option(SUBSURFACE_PROFILING_BUILD "enable profiling of Subsurface binary" OFF) @@ -110,6 +113,11 @@ if (SUBSURFACE_PROFILING_BUILD) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") endif() +# set up ASan +if (SUBSURFACE_ASAN_BUILD) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") +endif() # every compiler understands -Wall set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -- cgit v1.2.3-70-g09d2