diff --git a/CMakeLists.txt b/CMakeLists.txt index 90459a2ea..495b8d9c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ option(VIDEO_HW_DECODING "Set to ON to enable FFmpeg HW decoding" ${VIDEO_HW_DEC option(VLC_PLAYER "Set to ON to build the VLC-based video player" ${VLC_PLAYER}) option(CLANG_TIDY "Set to ON to build using the clang-tidy static analyzer" ${CLANG_TIDY}) option(ASAN "Set to ON to build with AddressSanitizer" ${ASAN}) +option(TSAN "Set to ON to build with ThreadSanitizer" ${TSAN}) if(CLANG_TIDY) find_program(CLANG_TIDY_BINARY NAMES clang-tidy) @@ -185,13 +186,26 @@ else() endif() endif() +if(ASAN AND TSAN) + message(FATAL_ERROR "-- AddressSanitizer and ThreadSanitizer can't be combined") +endif() + if(ASAN) message("-- Building with AddressSanitizer") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") - endif() + endif() +endif() + +if(TSAN) + message("-- Building with ThreadSanitizer") + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(FATAL_ERROR "-- ThreadSanitizer not available for MSVC") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") + endif() endif() # The following removes half of the ranlib warnings on macOS regarding no symbols for files