add_option(ZLIB_COMPAT "Compile with zlib compatible API" OFF)
add_option(ZLIB_ENABLE_TESTS "Build test binaries" ON)
add_option(ZLIB_DUAL_LINK "Dual link tests against system zlib" OFF)
-add_option(WITH_SANITIZER "Build with sanitizer (Memory, Address, Undefined)" OFF)
add_option(WITH_FUZZERS "Build test/fuzz" OFF)
add_option(WITH_OPTIM "Build with optimisation" ON)
add_option(WITH_NEW_STRATEGIES "Use new strategies" ON)
add_option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF)
add_option(WITH_UNALIGNED "Support unaligned reads on platforms that support it" ON)
+# Add multi-choice option
+set(WITH_SANITIZER AUTO CACHE STRING "Enable sanitizer support")
+set_property(CACHE WITH_SANITIZER PROPERTY STRINGS "Memory" "Address" "Undefined" "Thread")
+
if(BASEARCH_ARM_FOUND)
add_option(WITH_ACLE "Build with ACLE" ON)
add_option(WITH_NEON "Build with NEON intrinsics" ON)
add_address_sanitizer()
elseif(WITH_SANITIZER STREQUAL "Memory")
add_memory_sanitizer()
+elseif(WITH_SANITIZER STREQUAL "Thread")
+ add_thread_sanitizer()
elseif(WITH_SANITIZER STREQUAL "Undefined")
add_undefined_sanitizer()
endif()
endif()
endmacro()
+macro(add_thread_sanitizer)
+ check_sanitizer_support("thread" supported_checks)
+ if(NOT ${supported_checks} STREQUAL "")
+ message(STATUS "Thread sanitizer is enabled: ${supported_checks}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${supported_checks}")
+ else()
+ message(STATUS "Thread sanitizer is not supported")
+ endif()
+endmacro()
+
macro(add_undefined_sanitizer)
set(known_checks
array-bounds
else()
message(STATUS "UNdefined behavior sanitizer is not supported")
endif()
-endmacro()
\ No newline at end of file
+endmacro()