Add address sanitizer switch
Useful for debugging memory leaks and access violations. It is
not available on Windows though, and there is some problem compiling
ObjectiveC++ with it turned on.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a46679b..08ef25c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,6 +76,12 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
ENDIF()
+option(ENABLE_ASAN "Enable address sanitizer support" OFF)
+if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
+endif()
+
if(NOT DEFINED BUILD_WINVNC)
set(BUILD_WINVNC 1)
endif()