add cmake option to disable asan

This commit is contained in:
Jeffrey Hsu 2024-09-08 20:02:54 +08:00
parent 93cbf7c87b
commit a9a442b5ac
2 changed files with 30 additions and 10 deletions

View File

@ -4,22 +4,29 @@ project(Live\ Parise C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(FetchContent)
option(ENABLE_ASAN "Enable AddressSanitizer" ON)
add_compile_options(
-Wall
-Wextra
-O2
-g3
-fsanitize=address
-fsanitize=undefined
-fno-omit-frame-pointer
)
-g3)
add_link_options(
-fsanitize=address
-fsanitize=undefined
)
if (ENABLE_ASAN)
add_compile_options(
-fsanitize=address
-fsanitize=undefined
-fno-omit-frame-pointer
)
include(FetchContent)
add_link_options(
-fsanitize=address
-fsanitize=undefined
)
message("asan is on. if have any problems, disable it.")
endif ()
# For CURL
set(BUILD_STATIC_LIBS ON)

View File

@ -22,3 +22,16 @@ Set these vars to you need
const char SUBROOMID[] = ""; // at line 43 in main.c
const char SS[] = "";
```
### AddressSanitizer
Asan is enabled by default.
```bash
cmake .. -DENABLE_ASAN=OFF # disable asan
```
or
```CMake
option(ENABLE_ASAN "Enable AddressSanitizer" OFF) # at line 9
```
to disable it.