SetupAddressSanitizer.cmake 505 Bytes
Newer Older
1
# Optionally compile with thread sanitizer enabled to find memory bugs
2 3 4 5 6 7 8 9 10
# https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual

# Add optional sanitizer, off by default
option(ADDRESS_SANITIZER "Add address sanitizer" OFF)
if(ADDRESS_SANITIZER)
    add_compile_options(-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope -g)
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
endif()
message("-- Address Sanitizer: ${ADDRESS_SANITIZER}")