diff --git a/.editorconfig b/.editorconfig index 45620e343..5e6841ec0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -23,3 +23,7 @@ end_of_line = lf [CMakeLists.txt] indent_style = space indent_size = 2 + +[*.cmake] +indent_style = space +indent_size = 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d40b004d..bf235bb9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() option(ASAN "Enable address sanitizer" ON) +option(UBSAN "Enable undefined behaviour sanitizer" ON) option(DEBUG "Enable debug mode in engine" ON) option(SPAWN "Build the shareware version" OFF) option(DIST "Dynamically link only glibc and SDL2" OFF) @@ -19,6 +20,7 @@ option(NONET "Disable network" OFF) if(BINARY_RELEASE) set(CMAKE_BUILD_TYPE "Release") set(ASAN OFF) + set(UBSAN OFF) set(DEBUG OFF) set(DIST ON) set(FASTER OFF) @@ -37,6 +39,7 @@ endif() if(NIGHTLY_BUILD) set(CMAKE_BUILD_TYPE "RelWithDebInfo") set(ASAN OFF) + set(UBSAN OFF) set(DEBUG ON) set(DIST ON) set(FASTER OFF) @@ -305,6 +308,10 @@ foreach(target devilution devilutionx) target_compile_options(${target} PUBLIC -fsanitize=address -fsanitize-recover=address) target_link_libraries(${target} PUBLIC -fsanitize=address -fsanitize-recover=address) endif() + if(UBSAN) + target_compile_options(${target} PUBLIC -fsanitize=undefined) + target_link_libraries(${target} PUBLIC -fsanitize=undefined) + endif() endforeach(target devilution devilutionx) if(DIST AND CMAKE_CXX_COMPILER_ID MATCHES "GCC")