Skip to content

Commit 759347a

Browse files
committed
Enable sanitizer in debug builds
1 parent 33fb270 commit 759347a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ option(LIBSCRATCHCPP_BUILD_UNIT_TESTS "Build unit tests" ON)
1010
option(LIBSCRATCHCPP_NETWORK_SUPPORT "Support for downloading projects" ON)
1111
option(LIBSCRATCHCPP_PRINT_LLVM_IR "Print LLVM IR of compiled Scratch scripts (for debugging)" OFF)
1212

13+
if (CMAKE_BUILD_TYPE MATCHES "Debug")
14+
set(SANITIZER_FLAGS "-fsanitize=undefined -fsanitize=address -fno-omit-frame-pointer")
15+
set(CMAKE_CFLAGS ${CMAKE_CFLAGS} ${SANITIZER_FLAGS})
16+
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS})
17+
endif()
18+
1319
add_library(scratchcpp SHARED)
1420
add_subdirectory(src)
1521
include_directories(src) # TODO: Remove this line

0 commit comments

Comments
 (0)