Warning, /graphics/digikam/core/cmake/macros/MacroSanitizers.cmake is written in an unsupported language. File is not indexed.
0001 # An useful macro to manage sanitizer rules 0002 # 0003 # SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com> 0004 # 0005 # SPDX-License-Identifier: BSD-3-Clause 0006 # 0007 0008 macro(ENABLE_COMPILER_SANITIZERS) 0009 0010 if(ENABLE_SANITIZERS) 0011 0012 find_library(ASAN_LIBRARIES NAMES asan) 0013 0014 if (ASAN_LIBRARIES) 0015 0016 message(STATUS "Found AddressSanitizer library: ${ASAN_LIBRARIES}") 0017 set(ASAN_FOUND TRUE CACHE INTERNAL "") 0018 set(ECM_ENABLE_SANITIZERS ${ECM_ENABLE_SANITIZERS} "address") 0019 0020 else() 0021 0022 message(STATUS "Could not find AddressSanitizer library. Please install libasan...") 0023 0024 endif() 0025 0026 ### 0027 0028 find_library(LSAN_LIBRARIES NAMES lsan) 0029 0030 if (LSAN_LIBRARIES) 0031 0032 message(STATUS "Found LeakSanitizer library: ${LSAN_LIBRARIES}") 0033 set(LSAN_FOUND TRUE CACHE INTERNAL "") 0034 set(ECM_ENABLE_SANITIZERS ${ECM_ENABLE_SANITIZERS} "leak") 0035 0036 else() 0037 0038 message(STATUS "Could not find LeakSanitizer library. Please install liblsan...") 0039 0040 endif() 0041 0042 ### 0043 0044 find_library(UBSAN_LIBRARIES NAMES ubsan) 0045 0046 if (UBSAN_LIBRARIES) 0047 0048 message(STATUS "Found UndefinedBehaviorSanitizer library: ${UBSAN_LIBRARIES}") 0049 set(UBSAN_FOUND TRUE CACHE INTERNAL "") 0050 set(ECM_ENABLE_SANITIZERS ${ECM_ENABLE_SANITIZERS} "undefined") 0051 0052 else() 0053 0054 message(STATUS "Could not find UndefinedBehaviorSanitizer library. Please install libubsan...") 0055 0056 endif() 0057 0058 ### 0059 0060 find_library(MSAN_LIBRARIES NAMES msan) 0061 0062 if (MSAN_LIBRARIES) 0063 0064 message(STATUS "Found MemorySanitizer library: ${MSAN_LIBRARIES}") 0065 set(MSAN_FOUND TRUE CACHE INTERNAL "") 0066 set(ECM_ENABLE_SANITIZERS ${ECM_ENABLE_SANITIZERS} "memory") 0067 0068 else() 0069 0070 message(STATUS "Could not find MemorySanitizer library. Please install libmsan...") 0071 0072 endif() 0073 0074 ### 0075 0076 find_library(MSAN_LIBRARIES NAMES tsan) 0077 0078 if (TSAN_LIBRARIES) 0079 0080 message(STATUS "Found ThreadSanitizer library: ${TSAN_LIBRARIES}") 0081 set(TSAN_FOUND TRUE CACHE INTERNAL "") 0082 set(ECM_ENABLE_SANITIZERS ${ECM_ENABLE_SANITIZERS} "thread") 0083 0084 else() 0085 0086 message(STATUS "Could not find ThreadSanitizer library. Please install libtsan...") 0087 0088 endif() 0089 0090 ### 0091 0092 message(STATUS "Building with sanitizers: ${ECM_ENABLE_SANITIZERS}") 0093 0094 if ("${ECM_ENABLE_SANITIZERS}" STREQUAL "") 0095 0096 message(FATAL_ERROR "Could not find Sanitizer libraries") 0097 0098 endif() 0099 0100 include(ECMEnableSanitizers) 0101 0102 endif() 0103 0104 endmacro() 0105