aboutsummaryrefslogtreecommitdiff
path: root/cmake/compiler/clang
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-10-19 16:58:45 +0200
committerShauren <shauren.trinity@gmail.com>2021-12-18 23:03:00 +0100
commit58fe0f9e4acb4cdc83ea70e368d648abe457d54e (patch)
treedbce8277658ff2409a968ffff3acdb9a355ab052 /cmake/compiler/clang
parent7d63166ff3e819e3043f155b3df4007cccb81dee (diff)
Build/Misc: Add ASan CMake flag
Allow to enable/disable Address Sanitizer in Clang and GCC from CMake flag "ASAN" of type Boolean. It can be enabled passing -DASAN=TRUE to CMake. (cherry picked from commit 580f40769c6c446284dd1f5738f67fb3ee802956)
Diffstat (limited to 'cmake/compiler/clang')
-rw-r--r--cmake/compiler/clang/settings.cmake18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake
index 53ff022a7e0..cc756a92131 100644
--- a/cmake/compiler/clang/settings.cmake
+++ b/cmake/compiler/clang/settings.cmake
@@ -36,6 +36,24 @@ if(WITH_COREDEBUG)
message(STATUS "Clang: Debug-flags set (-g3)")
endif()
+if(ASAN)
+ target_compile_options(trinity-compile-option-interface
+ INTERFACE
+ -fno-omit-frame-pointer
+ -fsanitize=address
+ -fsanitize-recover=address
+ -fsanitize-address-use-after-scope)
+
+ target_link_options(trinity-compile-option-interface
+ INTERFACE
+ -fno-omit-frame-pointer
+ -fsanitize=address
+ -fsanitize-recover=address
+ -fsanitize-address-use-after-scope)
+
+ message(STATUS "Clang: Enabled Address Sanitizer")
+endif()
+
# -Wno-narrowing needed to suppress a warning in g3d
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
# -Wno-deprecated-copy needed to suppress a warning in g3d