summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2021-02-07 11:39:57 -0500
committerAllen Winter <allen.winter@kdab.com>2021-02-07 11:39:57 -0500
commitfc83696ff60f01b4051334f59edfc715d97a33f2 (patch)
treec589347f1e76e54db577e7a7dfb50eaac718e3da /CMakeLists.txt
parentced840fb01e45488885b3c8cb6a502f24e6bf990 (diff)
downloadlibical-git-fc83696ff60f01b4051334f59edfc715d97a33f2.tar.gz
CMakeLists.txt, scripts/buildtests.sh - add sanitize-undefined
pass -DUNDEFINED_SANITIZER=True to CMake in order to compile with --fsanitize=undefine add tests for this.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt30
1 files changed, 30 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5415d876..bae56128 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,6 +86,10 @@
# Build with the thread sanitizer (requires gcc or clang)
# Default=false
#
+# -DUNDEFINED_SANITIZER=[true|false]
+# Build with the undefined sanitizer (requires gcc or clang)
+# Default=false
+#
cmake_minimum_required(VERSION 3.11.0) #first line, to shutup a cygwin warning
project(libical C) #CXX is optional for the bindings
@@ -537,6 +541,32 @@ if(THREAD_SANITIZER)
endif()
endif()
+libical_option(UNDEFINED_SANITIZER "(Developer-only) Build with the undefined sanitizer." False)
+mark_as_advanced(UNDEFINED_SANITIZER)
+if(UNDEFINED_SANITIZER)
+ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -O1 -g -DUNDEFINED_SANITIZER -lubsan")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -O1 -g -DUNDEFINED_SANITIZER -lubsan")
+ else()
+ message(FATAL_ERROR
+ "You are trying to build with the undefined sanitizer using a non-GCC or Clang compiler.")
+ endif()
+ if(GOBJECT_INTROSPECTION)
+ message(STATUS
+ "Warning: Building the undefined sanitizer with GObject Introspection is is not supported. "
+ "Turning-off GObject Introspection."
+ )
+ set(HAVE_INTROSPECTION False)
+ endif()
+ if(ICAL_GLIB)
+ message(STATUS
+ "Warning: Building the undefined sanitizer with the GObject interface is not supported. "
+ "Turning-off the GObject interface."
+ )
+ set(ICAL_GLIB False)
+ endif()
+endif()
+
libical_option(ENABLE_LTO_BUILD "Build a link-time optimized version." False)
if(ENABLE_LTO_BUILD)
if(CMAKE_COMPILER_IS_GNUCC)