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/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake
index cc03487..25c1077 100644
--- a/cmake/StaticBuild.cmake
+++ b/cmake/StaticBuild.cmake
@@ -109,6 +109,9 @@
   # This ensures that we don't depend on libstdc++ or libgcc_s
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nodefaultlibs")
   set(STATIC_BASE_LIBRARIES "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic")
+  if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE)
+    set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-Bstatic -lasan -Wl,-Bdynamic -ldl -lm -lpthread")
+  endif()
   if(WIN32)
     set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt")
     set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -luser32 -lkernel32 -ladvapi32 -lshell32")