Skip to content

Commit

Permalink
cmake: enable AddressSanitizer for C++ and Release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Sep 7, 2022
1 parent 08e067d commit 1ce85cb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ASAN "Use AddressSanitizer for debug builds to detect memory issues" OFF)

if (ASAN)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} \
set(ASAN_FLAGS "\
-fsanitize=address \
-fsanitize=bool \
-fsanitize=bounds \
Expand All @@ -24,6 +24,8 @@ if (ASAN)
-fsanitize=leak \
-fsanitize=object-size \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ASAN_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_FLAGS}")
endif()

# Set a default build type if none was specified
Expand Down

0 comments on commit 1ce85cb

Please sign in to comment.