cmake: Disable ctime_tests if build with -fsanitize=memory

Clang >= 16 has `-fsanitize-memory-param-retval` turned on by default,
which is incompatible with
This commit is contained in:
Hennadii Stepanov
2024-05-28 09:37:00 +01:00
parent 1791f6fce4
commit 7abf979a43
2 changed files with 37 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
include_guard(GLOBAL)
include(CheckCSourceCompiles)
function(check_memory_sanitizer output)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
check_c_source_compiles("
#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
/* MemorySanitizer is enabled. */
# elif
# error \"MemorySanitizer is disabled.\"
# endif
#else
# error \"__has_feature is not defined.\"
#endif
" HAVE_MSAN)
set(${output} ${HAVE_MSAN} PARENT_SCOPE)
endfunction()