adding option to activate UB sanitizer

Signed-off-by: Stefano Fiorentino <stefano.fiore84@gmail.com>
This commit is contained in:
Stefano Fiorentino 2020-04-02 22:16:46 +02:00
parent 03b98bc234
commit 0ee7ef41fe
2 changed files with 13 additions and 2 deletions

View File

@ -38,6 +38,7 @@ message("*")
option(USE_LIBCPP "Use libc++ by adding -stdlib=libc++ flag if availbale." ON)
option(USE_ASAN "Use address sanitizer by adding -fsanitize=address -fno-omit-frame-pointer flags" OFF)
option(USE_UBSAN "Use address sanitizer by adding -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer flags" OFF)
option(BUILD_UVW_LIBS "Prepare targets for static and shared libraries rather than for a header-only library." OFF)
#
@ -112,7 +113,12 @@ else()
if(USE_ASAN)
target_compile_options(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
target_link_libraries(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
target_link_libraries(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=address>)
endif()
if(USE_UBSAN)
target_compile_options(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer>)
target_link_libraries(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=undefined>)
endif()
if(HAS_LIBCPP)

View File

@ -44,7 +44,12 @@ function(add_uvw_library LIB_NAME)
if(USE_ASAN)
target_compile_options(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
target_link_libraries(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
target_link_libraries(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=address>)
endif()
if(USE_UBSAN)
target_compile_options(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer>)
target_link_libraries(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=undefined>)
endif()
if(HAS_LIBCPP)