Add an option for -fsanitize=undefined

This commit is contained in:
kimden 2024-06-25 13:44:48 +04:00
parent 84dff4423e
commit f0af5ed992

View File

@ -111,6 +111,7 @@ endif()
if(UNIX AND NOT APPLE)
option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
option(USE_TSAN "Build with Thread sanitizer" OFF)
option(USE_USAN "Build with Undefined Behaviour sanitizer" OFF)
option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
endif()
@ -122,6 +123,10 @@ if(USE_TSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
endif()
if(USE_USAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
endif()
set(STK_SOURCE_DIR "src")
set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
@ -781,6 +786,9 @@ if(UNIX AND NOT APPLE)
if(USE_TSAN)
target_link_libraries(supertuxkart "-fsanitize=thread")
endif()
if(USE_USAN)
target_link_libraries(supertuxkart "-fsanitize=undefined")
endif()
endif()
if(BUILD_RECORDER)