aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-01-25 11:33:14 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-01-25 16:07:50 +0100
commitd41fd0c4653ff61afbc2808cfb96deba6decd7bd (patch)
tree2559c5321b12b0ba3c140a1089d0544cc6b65d11 /cmake
parentd598e4e52a08d91e129dd01fa2bcc2a0bc73d78c (diff)
downloadlibssh-d41fd0c4653ff61afbc2808cfb96deba6decd7bd.tar.gz
libssh-d41fd0c4653ff61afbc2808cfb96deba6decd7bd.tar.xz
libssh-d41fd0c4653ff61afbc2808cfb96deba6decd7bd.zip
cmake: Add support for MemorySanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/DefineCompilerFlags.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index 3277b990..c9aea580 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -23,6 +23,18 @@ if (UNIX AND NOT WIN32)
set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
CACHE STRING "Flags used by the linker during ADDRESSSANITIZER builds.")
+ # Activate with: -DCMAKE_BUILD_TYPE=MemorySanitizer
+ set(CMAKE_C_FLAGS_MEMORYSANITIZER "-g -O2 -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer"
+ CACHE STRING "Flags used by the C compiler during MEMORYSANITIZER builds.")
+ set(CMAKE_CXX_FLAGS_MEMORYSANITIZER "-g -O2 -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer"
+ CACHE STRING "Flags used by the CXX compiler during MEMORYSANITIZER builds.")
+ set(CMAKE_SHARED_LINKER_FLAGS_MEMORYSANITIZER "-fsanitize=memory"
+ CACHE STRING "Flags used by the linker during the creation of shared libraries during MEMORYSANITIZER builds.")
+ set(CMAKE_MODULE_LINKER_FLAGS_MEMORYSANITIZER "-fsanitize=memory"
+ CACHE STRING "Flags used by the linker during the creation of shared libraries during MEMORYSANITIZER builds.")
+ set(CMAKE_EXEC_LINKER_FLAGS_MEMORYSANITIZER "-fsanitize=memory"
+ CACHE STRING "Flags used by the linker during MEMORYSANITIZER builds.")
+
# Activate with: -DCMAKE_BUILD_TYPE=UndefinedSanitizer
set(CMAKE_C_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover"
CACHE STRING "Flags used by the C compiler during UNDEFINEDSANITIZER builds.")