CheckMemorySanitizer.cmake raw

   1  include_guard(GLOBAL)
   2  include(CheckCSourceCompiles)
   3  
   4  function(check_memory_sanitizer output)
   5    set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
   6    check_c_source_compiles("
   7      #if defined(__has_feature)
   8      #  if __has_feature(memory_sanitizer)
   9           /* MemorySanitizer is enabled. */
  10      #  elif
  11      #    error \"MemorySanitizer is disabled.\"
  12      #  endif
  13      #else
  14      #  error \"__has_feature is not defined.\"
  15      #endif
  16    " HAVE_MSAN)
  17    set(${output} ${HAVE_MSAN} PARENT_SCOPE)
  18  endfunction()
  19