File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ option(GIT_REVISION
17
17
option (UPDATE_CHECKER
18
18
"Enable or disable both the update checker and auto-updater" ON )
19
19
option (PRO_VERSION "Enable or disable Notes Pro features" ON )
20
+ option (ENABLE_ASAN "Enable address sanitizer" OFF )
20
21
21
22
project (
22
23
Notes
@@ -32,6 +33,13 @@ set(CMAKE_AUTOMOC ON)
32
33
set (CMAKE_AUTOUIC ON )
33
34
set (CMAKE_AUTORCC ON )
34
35
36
+ # address sanitizer can be enabled by running cmake with -DENABLE_ASAN=ON
37
+ if (ENABLE_ASAN AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
38
+ OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ))
39
+ set (ADDRESS_SANITIZER_FLAGS "-fsanitize=address -fno-omit-frame-pointer" )
40
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADDRESS_SANITIZER_FLAGS} " )
41
+ endif ()
42
+
35
43
if (POLICY CMP0083)
36
44
cmake_policy (SET CMP0083 NEW)
37
45
include (CheckPIESupported)
@@ -74,6 +82,10 @@ else()
74
82
message (STATUS "Build type: ${CMAKE_BUILD_TYPE} " )
75
83
endif ()
76
84
85
+ if (ENABLE_ASAN)
86
+ message (STATUS "Enabling AddressSanitizer" )
87
+ endif ()
88
+
77
89
set (GIT_REV "" )
78
90
if (GIT_REVISION)
79
91
if (EXISTS "${CMAKE_SOURCE_DIR} /.git" )
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ You should set those while invoking CMake to build the project. See the [example
10
10
| ` GIT_REVISION ` | ` OFF ` | ` ON ` / ` OFF ` | Append the current git revision to the app's version string |
11
11
| ` UPDATE_CHECKER ` | ` ON ` | ` ON ` / ` OFF ` | Enable or disable both the update checker and auto-updater |
12
12
| ` PRO_VERSION ` | ` ON ` | ` ON ` / ` OFF ` | Enable or disable Notes Pro features |
13
+ | ` ENABLE_ASAN ` | ` OFF ` | ` ON ` / ` OFF ` | Enable AddressSanitizer (ASan) for debugging |
13
14
14
15
### Examples
15
16
You can’t perform that action at this time.
0 commit comments