3
0
mirror of https://github.com/triqs/dft_tools synced 2024-09-16 17:35:31 +02:00

[cmake] Include build options for TSAN and MSAN

This commit is contained in:
Nils Wentzell 2023-07-07 16:32:42 -04:00
parent b463d5efe6
commit 089a5f5ab2

View File

@ -49,7 +49,7 @@ if(ANALYZE_SOURCES)
TARGET ${PROJECT_NAME}_c TARGET ${PROJECT_NAME}_c
COMMAND ${CPPCHECK_EXECUTABLE} COMMAND ${CPPCHECK_EXECUTABLE}
--enable=warning,style,performance,portability --enable=warning,style,performance,portability
--std=c++20 --std=c++23
--template=gcc --template=gcc
--verbose --verbose
--force --force
@ -64,21 +64,28 @@ if(ANALYZE_SOURCES)
endif() endif()
# ========= Dynamic Analyzer Checks ========== # ========= Dynamic Analyzer Checks ==========
option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer") option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer")
option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer")
if(ASAN) if(ASAN)
if(NOT TARGET asan) find_package(sanitizer REQUIRED COMPONENTS asan)
find_package(sanitizer REQUIRED "asan")
endif()
target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:asan>) target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:asan>)
endif() endif()
option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer")
if(UBSAN) if(UBSAN)
if(NOT TARGET ubsan) find_package(sanitizer REQUIRED COMPONENTS ubsan)
find_package(sanitizer REQUIRED "ubsan")
endif()
target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:ubsan>) target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:ubsan>)
endif() endif()
option(MSAN OFF "Compile library and executables with LLVM Memory Sanitizer")
if(MSAN)
find_package(sanitizer REQUIRED COMPONENTS msan)
target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:msan>)
endif()
option(TSAN OFF "Compile library and executables with LLVM Thread Sanitizer")
if(TSAN)
find_package(sanitizer REQUIRED COMPONENTS tsan)
target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:tsan>)
endif()