Skip to content

Commit 48582ec

Browse files
committed
Add AddressSanitizer to unit tester
1 parent b0bf7fc commit 48582ec

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1313

1414
project(OleanderStemTestRunner)
1515

16+
# Enable AddressSanitizer
17+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
18+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
19+
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
20+
add_link_options(-fsanitize=address)
21+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
22+
add_compile_options(/fsanitize=address)
23+
add_link_options(/fsanitize=address)
24+
endif()
25+
endif()
26+
1627
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
1728
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
1829

0 commit comments

Comments
 (0)