[cmake]: Add option for Address Sanitizer check

Change-Id: I91cf9111000d2e077dafd9871b965e864863e0bf
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen 2020-06-11 14:55:33 +08:00
parent c56c01494d
commit 0abeafe872
5 changed files with 16 additions and 4 deletions

View file

@ -172,6 +172,13 @@ if(GCC)
# for libary linking
set(BEGIN_WHOLE_ARCHIVE -Wl,--whole-archive)
set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
option(ASAN_CHECK "enable Address Sanitizer (Asan)" OFF)
if(ASAN_CHECK)
add_definitions(-fsanitize=address -static-libasan -g)
set(ASAN_LIB libasan.a dl rt m)
set(ASAN_BIN dl rt m)
endif(ASAN_CHECK)
endif(GCC)
# ----------------------------------------------------------------------------