aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2020-01-31 13:21:06 +0100
committerAndreas Schneider <asn@samba.org>2020-01-31 14:17:09 +0100
commit43b185e1696562ba17ea05e3574f030f911aa8cb (patch)
tree9da35ad685856953ec3fe2fc0b3656af5203ffd0
parenta4880ffaa12b61be8177c099e50e704a29e72f3b (diff)
downloadpam_wrapper-43b185e1696562ba17ea05e3574f030f911aa8cb.tar.gz
pam_wrapper-43b185e1696562ba17ea05e3574f030f911aa8cb.tar.xz
pam_wrapper-43b185e1696562ba17ea05e3574f030f911aa8cb.zip
cmake: Add AddressSanitizer and UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--cmake/Modules/DefineCompilerFlags.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index 4edb6d9..3277b99 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -10,4 +10,28 @@ if (UNIX AND NOT WIN32)
CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.")
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the linker during PROFILING builds.")
+
+ # Activate with: -DCMAKE_BUILD_TYPE=AddressSanitizer
+ set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer"
+ CACHE STRING "Flags used by the C compiler during ADDRESSSANITIZER builds.")
+ set(CMAKE_CXX_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer"
+ CACHE STRING "Flags used by the CXX compiler during ADDRESSSANITIZER builds.")
+ set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
+ CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.")
+ set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
+ CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.")
+ set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
+ CACHE STRING "Flags used by the linker during ADDRESSSANITIZER 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.")
+ set(CMAKE_CXX_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover"
+ CACHE STRING "Flags used by the CXX compiler during UNDEFINEDSANITIZER builds.")
+ set(CMAKE_SHARED_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
+ CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
+ set(CMAKE_MODULE_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
+ CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
+ set(CMAKE_EXEC_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
+ CACHE STRING "Flags used by the linker during UNDEFINEDSANITIZER builds.")
endif()