Added a ThreadSanitizer option to the CMake configuration file.

This commit is contained in:
Leon Styhre 2021-11-15 20:22:29 +01:00
parent aeae1ba10e
commit 634a58fbc3

View file

@ -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(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(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(ASAN "Set to ON to build with AddressSanitizer" ${ASAN})
option(TSAN "Set to ON to build with ThreadSanitizer" ${TSAN})
if(CLANG_TIDY) if(CLANG_TIDY)
find_program(CLANG_TIDY_BINARY NAMES clang-tidy) find_program(CLANG_TIDY_BINARY NAMES clang-tidy)
@ -185,6 +186,10 @@ else()
endif() endif()
endif() endif()
if(ASAN AND TSAN)
message(FATAL_ERROR "-- AddressSanitizer and ThreadSanitizer can't be combined")
endif()
if(ASAN) if(ASAN)
message("-- Building with AddressSanitizer") message("-- Building with AddressSanitizer")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
@ -194,6 +199,15 @@ if(ASAN)
endif() 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 # The following removes half of the ranlib warnings on macOS regarding no symbols for files
# that are #ifdef'ed away. There must be a way to remove the other half as well? # that are #ifdef'ed away. There must be a way to remove the other half as well?
if(APPLE) if(APPLE)