3
0
mirror of https://github.com/triqs/dft_tools synced 2025-01-03 10:05:49 +01:00

[cmake] Protect against redefining santizier targets

This commit is contained in:
Nils Wentzell 2023-08-04 14:52:46 -04:00
parent cb99846580
commit c0afc3c44b

View File

@ -68,24 +68,32 @@ endif()
option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer") option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer")
if(ASAN) if(ASAN)
find_package(sanitizer REQUIRED COMPONENTS asan) if(NOT TARGET ASAN)
find_package(sanitizer REQUIRED COMPONENTS 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") option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer")
if(UBSAN) if(UBSAN)
find_package(sanitizer REQUIRED COMPONENTS ubsan) if(NOT TARGET UBSAN)
find_package(sanitizer REQUIRED COMPONENTS 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") option(MSAN OFF "Compile library and executables with LLVM Memory Sanitizer")
if(MSAN) if(MSAN)
find_package(sanitizer REQUIRED COMPONENTS msan) if(NOT TARGET MSAN)
find_package(sanitizer REQUIRED COMPONENTS msan)
endif()
target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:msan>) target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:msan>)
endif() endif()
option(TSAN OFF "Compile library and executables with LLVM Thread Sanitizer") option(TSAN OFF "Compile library and executables with LLVM Thread Sanitizer")
if(TSAN) if(TSAN)
find_package(sanitizer REQUIRED COMPONENTS tsan) if(NOT TARGET TSAN)
find_package(sanitizer REQUIRED COMPONENTS tsan)
endif()
target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:tsan>) target_link_libraries(${PROJECT_NAME}_c PUBLIC $<BUILD_INTERFACE:tsan>)
endif() endif()