diff CMakeLists.txt @ 176:408e4823e378

cmake: add sone -fsanitize in Debug builds
author David Demelier <markand@malikania.fr>
date Fri, 23 Oct 2020 09:30:54 +0200
parents c577c15df07f
children 6a15145b331e
line wrap: on
line diff
--- a/CMakeLists.txt	Thu Oct 22 15:27:57 2020 +0200
+++ b/CMakeLists.txt	Fri Oct 23 09:30:54 2020 +0200
@@ -28,6 +28,12 @@
 	set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}")
 endif ()
 
+if (CMAKE_C_COMPILER_ID MATCHES "Clang")
+	set(options "-fsanitize=address -fsanitize=undefined -fsanitize=integer")
+	set(CMAKE_C_FLAGS_DEBUG "-fno-omit-frame-pointer ${options} ${CMAKE_C_FLAGS_DEBUG}")
+	set(CMAKE_EXE_LINKER_FLAGS "${options} ${CMAKE_EXE_LINKER_FLAGS}")
+endif ()
+
 set_property(GLOBAL PROPERTY USE_FOLDERS On)
 
 include(GNUInstallDirs)