File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 11# build directory
22/cmake-build-debug /
3+ /cmake-build-release /
4+ /cmake-build-sanitize /
35
46# ide settings
57/.idea
Original file line number Diff line number Diff line change @@ -5,9 +5,22 @@ project(objcurses)
55
66set (CMAKE_CXX_STANDARD 20)
77
8+ # address sanitizer
9+ option (SANITIZE "enable AddressSanitizer with extended checks" OFF )
10+
11+ if (SANITIZE)
12+ message (STATUS "AddressSanitizer enabled" )
13+ set (ASAN_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g" )
14+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_FLAGS} " )
15+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_FLAGS} " )
16+
17+ # embed runtime ASAN options into binary
18+ add_compile_definitions (ASAN_OPTIONS="detect_leaks=1:strict_string_checks=1:check_initialization_order=1:detect_stack_use_after_return=1:detect_container_overflow=1:abort_on_error=1" )
19+ endif ()
20+
821# collect all source files recursively, excluding build directory
922file (GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR} /*.cpp" )
10- list (FILTER SOURCES EXCLUDE REGEX "${CMAKE_BINARY_DIR} " )
23+ list (FILTER SOURCES EXCLUDE REGEX ".*/.*build.*/.* " )
1124
1225# creating executable
1326add_executable (${PROJECT_NAME} ${SOURCES} )
@@ -19,4 +32,4 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${CURSES_LIBRARIES})
1932target_include_directories (${PROJECT_NAME} PRIVATE ${CURSES_INCLUDE_DIR} )
2033
2134# linking math library
22- target_link_libraries (${PROJECT_NAME} PRIVATE m)
35+ target_link_libraries (${PROJECT_NAME} PRIVATE m)
Original file line number Diff line number Diff line change 1818#include " config.h"
1919#include " version.h"
2020
21+ #ifdef ASAN_OPTIONS
22+ extern " C" const char *__asan_default_options () {
23+ return ASAN_OPTIONS;
24+ }
25+ #endif
26+
27+
2128// ncurses
2229
2330void init_ncurses ()
You can’t perform that action at this time.
0 commit comments