Commit Diff


commit - ae9c0785c0598df322cc1880c330f0c9f3f36f2d
commit + 927554b6d8fdd8c1e3783f422bf8ca53a16220d5
blob - 5826566e4fbecd7e1d9a7a994280c9c891b3d0d8
blob + 4e026e1b6b1eb5b9c15191dc857f1480a90ff976
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -37,6 +37,20 @@ if (${HAVE_XATTR})
     target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_XATTR)
 endif ()
 
+option(ENABLE_ASAN "Enable AddressSanitizer, a fast memory error detector
+                    based on compiler instrumentation" OFF)
+if(ENABLE_ASAN)
+    target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=address)
+    target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=address)
+endif()
+
+option(ENABLE_UBSAN "Enable UBSanitizer, undefined behaviour
+                     detector based on compiler instrumentation" OFF)
+if(ENABLE_UBSAN)
+    target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=undefined)
+    target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=undefined)
+endif()
+
 enable_testing()
 add_subdirectory(tests)
 add_test(NAME pytest COMMAND pytest -c ${PROJECT_SOURCE_DIR}/tests/pytest.ini ${PROJECT_SOURCE_DIR}/tests/