[cmake] add USE_ASAN option to build with addresssanitizer

pull/2292/head
nick black 3 years ago
parent 06de7ac582
commit 7071cb42fa

@ -12,6 +12,7 @@ include(FeatureSummary)
###################### USER-SELECTABLE OPTIONS ###########################
# BUILD_TESTING is defined by CTest
option(DFSG_BUILD "DFSG build (no non-free media/code)" OFF)
option(USE_ASAN "Build with AddressSanitizer" OFF)
option(USE_COVERAGE "Assess code coverage with llvm-cov/lcov" OFF)
option(USE_CPP "Build C++ code" ON)
cmake_dependent_option(
@ -118,6 +119,11 @@ endif()
add_compile_options(-Wall -Wextra -W -Wshadow)
add_compile_options(-ffast-math -fexceptions -fstrict-aliasing)
if(${USE_ASAN})
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
# don't use REQUIRED with subsequent find_package() operations; we use
# feature_summary + set_package_properties to fail in one fell swoop.
find_package(Threads)

@ -95,6 +95,7 @@ but must be `Debug` for use of `USE_COVERAGE`.
* `DFSG_BUILD`: leave out all content considered non-free under the Debian Free
Software Guidelines
* `BUILD_TESTING`: build test targets
* `USE_ASAN`: build with AddressSanitizer
* `USE_CPP`: build C++ code (requires a C++ compiler)
* `USE_COVERAGE`: build coverage support (for developers, requires use of Clang)
* `USE_DOCTEST`: build `notcurses-tester` with Doctest, requires `BUILD_TESTING`

Loading…
Cancel
Save