From c0afc3c44b7abdd70747eee42d10e6d7a920cf4f Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Fri, 4 Aug 2023 14:52:46 -0400 Subject: [PATCH] [cmake] Protect against redefining santizier targets --- c++/app4triqs/CMakeLists.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/c++/app4triqs/CMakeLists.txt b/c++/app4triqs/CMakeLists.txt index 12ea5998..308acf2f 100644 --- a/c++/app4triqs/CMakeLists.txt +++ b/c++/app4triqs/CMakeLists.txt @@ -68,24 +68,32 @@ endif() option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer") 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 $) endif() option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer") 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 $) endif() option(MSAN OFF "Compile library and executables with LLVM Memory Sanitizer") 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 $) endif() option(TSAN OFF "Compile library and executables with LLVM Thread Sanitizer") 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 $) endif()