From b812d3303748704d5582a16a5d095d03955fe900 Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Fri, 17 Aug 2018 16:59:09 -0700 Subject: [PATCH] cmake: Add ASAN support. --- CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4f5fa79..204e10169 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ option(ENABLE_GPL "Enable GPL dependencies" OFF) # General build options # >> 3-valued: INGORE ON OFF, allows to detect if set by user # this is only necessary for options set for build types! +cvc4_option(ENABLE_ASAN "Enable ASAN build") cvc4_option(ENABLE_ASSERTIONS "Enable assertions") cvc4_option(ENABLE_DEBUG_SYMBOLS "Enable debug symbols") cvc4_option(ENABLE_DUMPING "Enable dumpin") @@ -191,12 +192,17 @@ include_directories(${GMP_INCLUDE_DIR}) add_check_c_cxx_flag("-O${OPT_LEVEL}") add_check_c_flag("-fexceptions") add_check_c_cxx_flag("-Wno-deprecated") -add_check_c_cxx_flag("-Wsuggest-override") +add_check_cxx_flag("-Wsuggest-override") add_check_cxx_flag("-Wnon-virtual-dtor") #-----------------------------------------------------------------------------# # Build types +if(ENABLE_ASAN) + set(CMAKE_BUILD_TYPE Debug) +endif() + +# Set the default build type to Production if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Production CACHE STRING "Options are: ${BUILD_TYPES}" FORCE) # Provide drop down menu options in cmake-gui @@ -220,6 +226,14 @@ endif() #-----------------------------------------------------------------------------# +if(ENABLE_ASAN) + set(CMAKE_REQUIRED_LIBRARIES -fsanitize=address) + add_required_c_cxx_flag("-fsanitize=address") + unset(CMAKE_REQUIRED_LIBRARIES) + add_required_c_cxx_flag("-fno-omit-frame-pointer") + add_check_c_cxx_flag("-fsanitize-recover=address") +endif() + if(ENABLE_ASSERTIONS) add_definitions(-DCVC4_ASSERTIONS) endif() -- 2.30.2