Warning, /rolisteam/rolisteam/cmake/Sanitizers.cmake is written in an unsupported language. File is not indexed.
0001 function(enable_sanitizers project_name) 0002 0003 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") 0004 option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang" FALSE) 0005 0006 if(ENABLE_COVERAGE) 0007 target_compile_options(${project_name} INTERFACE --coverage -O0 -g) 0008 target_link_libraries(${project_name} INTERFACE --coverage) 0009 endif() 0010 0011 set(SANITIZERS "") 0012 0013 option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" FALSE) 0014 if(ENABLE_SANITIZER_ADDRESS) 0015 list(APPEND SANITIZERS "address") 0016 endif() 0017 0018 option(ENABLE_SANITIZER_LEAK "Enable leak sanitizer" FALSE) 0019 if(ENABLE_SANITIZER_LEAK) 0020 list(APPEND SANITIZERS "leak") 0021 endif() 0022 0023 option(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Enable undefined behavior sanitizer" FALSE) 0024 if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR) 0025 list(APPEND SANITIZERS "undefined") 0026 endif() 0027 0028 option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" FALSE) 0029 if(ENABLE_SANITIZER_THREAD) 0030 if("address" IN_LIST SANITIZERS OR "leak" IN_LIST SANITIZERS) 0031 message(WARNING "Thread sanitizer does not work with Address and Leak sanitizer enabled") 0032 else() 0033 list(APPEND SANITIZERS "thread") 0034 endif() 0035 endif() 0036 0037 option(ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" FALSE) 0038 if(ENABLE_SANITIZER_MEMORY AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") 0039 if("address" IN_LIST SANITIZERS 0040 OR "thread" IN_LIST SANITIZERS 0041 OR "leak" IN_LIST SANITIZERS) 0042 message(WARNING "Memory sanitizer does not work with Address, Thread and Leak sanitizer enabled") 0043 else() 0044 list(APPEND SANITIZERS "memory") 0045 endif() 0046 endif() 0047 0048 list( 0049 JOIN 0050 SANITIZERS 0051 "," 0052 LIST_OF_SANITIZERS) 0053 0054 endif() 0055 0056 if(LIST_OF_SANITIZERS) 0057 if(NOT 0058 "${LIST_OF_SANITIZERS}" 0059 STREQUAL 0060 "") 0061 target_compile_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS}) 0062 target_link_libraries(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS}) 0063 endif() 0064 endif() 0065 0066 endfunction()