zhangmeng
2024-04-22 16935f4aebffdd1b6580b844391a0aa0f4f3012b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
# Copyright 2017 Capitar IT Group BV <info@capitar.com>
#
# This software is supplied under the terms of the MIT License, a
# copy of which should be located in the distribution where this
# file was obtained (LICENSE.txt).  A copy of the license may also be
# found online at https://opensource.org/licenses/MIT.
#
 
macro (CheckSanitizer)
 
    if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
        set(NNG_SAN_LIST none address leak memory thread undefined)
    elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
        set(NNG_SAN_LIST none address leak memory thread undefined)
    elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
        set(NNG_SAN_LIST none address thread undefined) 
    else ()
        set(NNG_SAN_LIST none)
    endif ()
    set (NNG_SANITIZER none CACHE STRING "Sanitizer to use (clang or gcc).")
    set_property(CACHE NNG_SANITIZER PROPERTY STRINGS ${NNG_SAN_LIST})
    mark_as_advanced (NNG_SANITIZER)
 
    if (NOT NNG_SANITIZER STREQUAL "none")
        set (NNG_C_FLAG_SANITIZER "-fsanitize=${NNG_SANITIZER}")
        message(STATUS "Enabling sanitizer: ${NNG_C_FLAG_SANITIZER}")
    endif()
endmacro ()