aboutsummaryrefslogtreecommitdiff
path: root/modules/ECMEnableSanitizers.cmake
diff options
context:
space:
mode:
authorl10n daemon script <scripty@kde.org>2015-11-08 21:01:33 +0000
committerl10n daemon script <scripty@kde.org>2015-11-08 21:01:33 +0000
commit7feccae76e01a65b406995b5ba9526fe9ade4299 (patch)
tree99011137f4dedcf4bf242e167ac7dc70d9136b8e /modules/ECMEnableSanitizers.cmake
parenta1bb0b0488843165e606771b75a3a67ba8a131a6 (diff)
parentc88bc78e0ca3834c46b89ca9d14b404751da5d4a (diff)
downloadextra-cmake-modules-5.16.0-rc2.tar.gz
extra-cmake-modules-5.16.0-rc2.tar.bz2
Merge remote-tracking branch 'origin/master' into local_releasev5.16.0-rc2v5.16.0
Diffstat (limited to 'modules/ECMEnableSanitizers.cmake')
-rw-r--r--modules/ECMEnableSanitizers.cmake69
1 files changed, 38 insertions, 31 deletions
diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake
index a0df80e2..e64599b6 100644
--- a/modules/ECMEnableSanitizers.cmake
+++ b/modules/ECMEnableSanitizers.cmake
@@ -2,9 +2,10 @@
# ECMEnableSanitizers
# -------------------
#
-# Enable compiler sanitizer flags
+# Enable compiler sanitizer flags.
+#
+# The following sanitizers are supported:
#
-# The following sanitizers are supported :
# - Address Sanitizer
# - Memory Sanitizer
# - Thread Sanitizer
@@ -14,53 +15,59 @@
# All of them are implemented in Clang, depending on your version, and
# there is an work in progress in GCC, where some of them are currently
# implemented.
-# This module will check your current compiler version to see if it support
-# the sanitizers that you want to enable
#
-# How to use it ?
-# ---------------
-# This module is included in KDECompilerSettings. Therefore you don't have
-# to change your CMakeLists.txt
+# This module will check your current compiler version to see if it
+# supports the sanitizers that you want to enable
+#
+# Usage
+# =====
+#
+# Simply add::
+#
+# include(ECMEnableSanitizers)
+#
+# to your ``CMakeLists.txt``. Note that this module is included in
+# KDECompilerSettings, so projects using that module do not need to also
+# include this one.
#
-# It introduce a new cached variable :
-# ECM_ENABLE_SANITIZERS
+# The sanitizers are not enabled by default. Instead, you must set
+# ``ECM_ENABLE_SANITIZERS`` (either in your ``CMakeLists.txt`` or on the
+# command line) to a semicolon-separated list of sanitizers you wish to enable.
+# The options are:
#
-# which can take the following values :
# - address
# - memory
# - thread
# - leak
# - undefined
#
-# You can enable two sanitizers in the same build, depending on their
-# compatibility by separating each one with a semicolon :
-# ECM_ENABLE_SANITIZERS='address;undefined'
+# The sanitizers "address", "memory" and "thread" are mutually exclusive. You
+# cannot enable two of them in the same build.
#
+# "leak" requires the "address" sanitizer.
#
-# The sanitizers `address`, `memory` and `thread` are mutually exclusive.
-# You cannot enable two of them in the same build.
+# .. note::
#
-# `undefined` can be used with every other sanitizers
+# To reduce the overhead induced by the instrumentation of the sanitizers, it
+# is advised to enable compiler optimizations (``-O1`` or higher).
#
-# `leak` can be enable with the `address` sanitizer.
+# Example
+# =======
#
-# Finally, to reduce the overhead induced by the instrumentation of the
-# sanitizers, it is advised to use -O1, or higher to improve the performances.
+# This is an example of usage::
#
-# Example
-# -------
-# This is an example of usage :
-# mkdir _build
-# cd _build
-# cmake -DECM_ENABLE_SANITIZERS='address' ..
+# mkdir build
+# cd build
+# cmake -DECM_ENABLE_SANITIZERS='address;leak;undefined' ..
#
-# If you want to use multiple sanitizers
+# .. note::
#
-# cmake -DECM_ENABLE_SANITIZERS='address;leak;undefined' ..
+# Most of the sanitizers will require Clang. To enable it, use::
#
-# => Most of the sanitizers will require Clang. To enable it, use :
-# -DCMAKE_CXX_COMPILER=clang++
+# -DCMAKE_CXX_COMPILER=clang++
#
+# Since 1.3.0.
+
#=============================================================================
# Copyright 2014 Mathieu Tarral <mathieu.tarral@gmail.com>
#
@@ -118,7 +125,7 @@ macro (enable_sanitizer_flags sanitize_option)
set(XSAN_COMPILE_FLAGS "-fsanitize=leak")
set(XSAN_LINKER_FLAGS "lsan")
elseif (${sanitize_option} MATCHES "undefined")
- check_compiler_version("99.99" "3.1")
+ check_compiler_version("4.9" "3.1")
set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls")
else ()
message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.")