aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 32a8f81..c51c2aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,8 @@ option(NIHIL_CONFIG "Build the nihil.config library" ON)
option(NIHIL_UCL "Build the nihil.ucl library" ON)
option(NIHIL_TESTS "Build nihil's unit tests" ON)
option(NIHIL_TIDY "Run clang-tidy during build" ON)
+option(NIHIL_ASAN "Enable Address Sanitizer" OFF)
+option(NIHIL_UBSAN "Enable Undefined Behaviour Sanitizer" OFF)
set(CMAKE_CXX_STANDARD 26)
@@ -41,6 +43,16 @@ add_compile_options(-Wextra)
add_compile_options(-Werror)
add_compile_options(-Wpedantic)
+if(NIHIL_ASAN)
+ add_compile_options(-fsanitize=address)
+ add_link_options(-fsanitize=address)
+endif()
+
+if(NIHIL_UBSAN)
+ add_compile_options(-fsanitize=undefined)
+ add_link_options(-fsanitize=undefined)
+endif()
+
# Enable libc++ hardening
add_compile_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE)
='n118' href='#n118'>118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163