CMake option to turn on the AddressSanitizer (#22985)

This commit is contained in:
mrmbernardi 2024-10-15 20:11:47 +11:00 committed by GitHub
parent ff07f09fe7
commit 498a2e349b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,6 +110,8 @@ option(DISABLE_HTTP "Disable HTTP support.")
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
option(ENABLE_SCRIPTING "Enable script / plugin support." ON)
option(ENABLE_ASAN "Enable the AddressSanitizer.")
option(ENABLE_UBSAN "Enable the UndefinedBehaviourSanitizer.")
option(DISABLE_GUI "Don't build GUI. (Headless only.)")
@ -396,6 +398,14 @@ endif ()
if (ENABLE_SCRIPTING)
target_compile_options(libopenrct2 PUBLIC -DENABLE_SCRIPTING)
endif ()
if (ENABLE_ASAN)
target_compile_options(libopenrct2 PUBLIC -fsanitize=address)
target_link_options(libopenrct2 PUBLIC -fsanitize=address)
endif ()
if (ENABLE_UBSAN)
target_compile_options(libopenrct2 PUBLIC -fsanitize=undefined)
target_link_options(libopenrct2 PUBLIC -fsanitize=undefined)
endif ()
# g2