Added an AddressSanitizer option to the CMake configuration file.

This commit is contained in:
Leon Styhre 2021-11-13 13:28:36 +01:00
parent 36b7146d7f
commit 4b62650166

View file

@ -36,6 +36,7 @@ option(CEC "Set to ON to enable CEC" ${CEC})
option(VIDEO_HW_DECODING "Set to ON to enable FFmpeg HW decoding" ${VIDEO_HW_DECODING}) option(VIDEO_HW_DECODING "Set to ON to enable FFmpeg HW decoding" ${VIDEO_HW_DECODING})
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 using AddressSanitizer" ${ASAN})
if(CLANG_TIDY) if(CLANG_TIDY)
find_program(CLANG_TIDY_BINARY NAMES clang-tidy) find_program(CLANG_TIDY_BINARY NAMES clang-tidy)
@ -184,6 +185,15 @@ else()
endif() endif()
endif() 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()
# 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)