cmake: enable AddressSanitizer in Debug builds

This commit is contained in:
Christian Rauch 2020-06-19 00:05:12 +01:00
parent ce0e2096b5
commit 5df88303d2

View File

@ -66,6 +66,25 @@ if (GLFW_BUILD_DOCS)
find_package(Doxygen)
endif()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} \
-fsanitize=address \
-fsanitize=bool \
-fsanitize=bounds \
-fsanitize=enum \
-fsanitize=float-cast-overflow \
-fsanitize=float-divide-by-zero \
-fsanitize=nonnull-attribute \
-fsanitize=returns-nonnull-attribute \
-fsanitize=signed-integer-overflow \
-fsanitize=undefined \
-fsanitize=vla-bound \
-fno-sanitize=alignment \
-fsanitize=leak \
-fsanitize=object-size \
")
endif()
#--------------------------------------------------------------------
# Set compiler specific flags
#--------------------------------------------------------------------