Skip to content

Commit

Permalink
Make Sanitizers optional for releases
Browse files Browse the repository at this point in the history
Released version should have sanitizers turned off since they are not very
helpful for normal users.
  • Loading branch information
dariusarnold committed Apr 5, 2023
1 parent f1c9752 commit abc2175
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(game_boy_emulator)

set(CMAKE_CXX_STANDARD 20)

option(SANITIZE "Enable address and undefined behavior sanitizers" ON)

find_package(fmt REQUIRED)
find_package(Catch2 REQUIRED)
find_package(SDL2 REQUIRED)
Expand Down Expand Up @@ -31,8 +33,11 @@ else()
message(STATUS "clang-tidy is only active for clang, disabling checks")
endif ()

add_compile_options(-fsanitize=address,undefined)
add_link_options(-fsanitize=address,undefined)
if (SANITIZE)
message(STATUS "Sanitizers were enabled")
add_compile_options(-fsanitize=address,undefined)
add_link_options(-fsanitize=address,undefined)
endif ()

add_subdirectory(src)
add_subdirectory(src/tests)

0 comments on commit abc2175

Please sign in to comment.