diff --git a/CMakeLists.txt b/CMakeLists.txt index e40c750f2ac85ce7bff0220986353fdebdbdde23..f4649621086309eab7e13932124703a88c4fe8ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,21 @@ if (ENABLE_CUSTOM_COMPILER_FLAGS) ) endif() +option(ENABLE_SANITIZERS "Enables AddressSanitizer and UndefinedBehaviorSanitizer." OFF) +if (ENABLE_SANITIZERS) + list(APPEND custom_compiler_flags + -fno-omit-frame-pointer + -fsanitize=address + -fsanitize=undefined + -fsanitize=float-divide-by-zero + -fsanitize=float-cast-overflow + -fsanitize-address-use-after-scope + -fsanitize=integer + -01 + -fno-sanitize-recover + ) +endif() + # apply custom compiler flags foreach(compiler_flag ${custom_compiler_flags}) #remove problematic characters