SetupThreadSanitizer.cmake 494 Bytes
Newer Older
1 2 3 4 5
# Optionally compile with thread sanitizer enabled to find concurrency bugs
# https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual

# Add optional sanitizer, off by default
option(THREAD_SANITIZER "Add thread sanitizer" OFF)
6 7 8 9
if (THREAD_SANITIZER)
    add_compile_options(-fsanitize=thread -g -fno-omit-frame-pointer)
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
endif ()
10
message("-- Thread Sanitizer: ${THREAD_SANITIZER}")