How it works

The core ingredients for this recipe are in the following section of CMakeLists.txt:

option(ENABLE_TSAN "Enable ThreadSanitizer" OFF)if(ENABLE_TSAN)  if(CMAKE_CXX_COMPILER_ID MATCHES GNU)    message(STATUS "ThreadSanitizer enabled")    target_compile_options(example      PUBLIC        -g -O1 -fsanitize=thread -fno-omit-frame-pointer -fPIC      )    target_link_libraries(example      PUBLIC        tsan      )  else()    message(WARNING "ThreadSanitizer not supported for this compiler")  endif()endif()

The ingredients are also in the updated steps in dashboard.cmake:

# ...ctest_start(Experimental)ctest_configure(  OPTIONS    -DENABLE_TSAN:BOOL=ON  )ctest_build()ctest_test()set(CTEST_MEMORYCHECK_TYPE "ThreadSanitizer")ctest_memcheck()ctest_submit()

As in the previous recipe, we can ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.