Added an UndefinedBehaviorSanitizer option to the CMake configuration file.

This commit is contained in:
Leon Styhre 2021-11-16 20:18:09 +01:00
parent 9937476e18
commit c5c7835dbb

View file

@ -38,6 +38,7 @@ 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})
option(UBSAN "Set to ON to build with UndefinedBehaviorSanitizer" ${UBSAN})
if(CLANG_TIDY)
find_program(CLANG_TIDY_BINARY NAMES clang-tidy)
@ -213,6 +214,15 @@ if(TSAN)
endif()
endif()
if(UBSAN)
message("-- Building with UndefinedBehaviorSanitizer")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message(FATAL_ERROR "-- UndefinedBehaviorSanitizer not available for MSVC")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
endif()
# 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?
if(APPLE)