Skip to content

Commit

Permalink
Build Source and SourceX with UBSAN by default
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm authored and AJenbo committed Oct 9, 2019
1 parent ed2a8b1 commit 1ea70f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ end_of_line = lf
[CMakeLists.txt]
indent_style = space
indent_size = 2

[*.cmake]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 1ea70f8

Please sign in to comment.