From 6c7316408bf0b16adbbb152a3e3275a3995fa4e1 Mon Sep 17 00:00:00 2001 From: brain5lug Date: Sat, 17 Sep 2016 11:00:21 +0300 Subject: [PATCH] address sanitizer configuration option have been added --- build/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index dda0a67c..61b8fdf9 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -16,6 +16,7 @@ option(WITH_UPNP "Include support for UPnP client" OFF) option(WITH_PCH "Use precompiled header" OFF) option(WITH_GUI "Include GUI (currently MS Windows only)" ON) option(WITH_MESHNET "Build for cjdns test network" OFF) +option(WITH_ADDRSANITIZER "Build with address sanitizer (linux only)" OFF) # paths set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) @@ -183,6 +184,15 @@ if (WITH_AESNI) add_definitions ( -DAESNI ) endif() +if (WITH_ADDRSANITIZER) + if (NOT MSVC) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address" ) + else () + error ("MSVC does not support address sanitizer option") + endif() +endif() + # libraries # TODO: once CMake 3.1+ becomes mainstream, see e.g. http://stackoverflow.com/a/29871891/673826 # use imported Threads::Threads instead @@ -335,6 +345,7 @@ message(STATUS " STATIC BUILD : ${WITH_STATIC}") message(STATUS " UPnP : ${WITH_UPNP}") message(STATUS " PCH : ${WITH_PCH}") message(STATUS " MESHNET : ${WITH_MESHNET}") +message(STATUS " ADDRSANITIZER : ${WITH_ADDRSANITIZER}") message(STATUS "---------------------------------------") #Handle paths nicely