From df33cb6ffd1b7dc3ea928f6b5400aaa8792a198a Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Mon, 16 Sep 2019 14:39:27 -0400 Subject: [PATCH] [cmake] Clean c++/app4triqs/CMakeLists.txt after recent additions to triqs Findsanitizer.cmake --- c++/app4triqs/CMakeLists.txt | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/c++/app4triqs/CMakeLists.txt b/c++/app4triqs/CMakeLists.txt index ab8835a8..8a1b1c24 100644 --- a/c++/app4triqs/CMakeLists.txt +++ b/c++/app4triqs/CMakeLists.txt @@ -59,32 +59,16 @@ endif() # ========= Dynamic Analyzer Checks ========== -set(sanitizers "") -# Address Sanitizer option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer") -if(ASAN) - list(APPEND sanitizers asan) - target_compile_options(app4triqs_c PRIVATE -fsanitize=address -fno-omit-frame-pointer -ggdb3) - target_link_libraries(app4triqs_c INTERFACE "-fsanitize=address -fno-omit-frame-pointer") - if(NOT DEFINED ENV{ASAN_OPTIONS}) - message(WARNING "ASAN_OPTIONS is not set. Consider setting ASAN_OPTIONS=symbolize=1:detect_leaks=0 when running tests") - endif() -endif() - -# Undefined Behavior Sanitizer option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer") -if(UBSAN) - list(APPEND sanitizers ubsan) - target_compile_options(app4triqs_c PUBLIC -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-omit-frame-pointer -ggdb3) - target_link_libraries(app4triqs_c INTERFACE "-fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-omit-frame-pointer") - if(NOT DEFINED ENV{UBSAN_OPTIONS}) - message(WARNING "UBSAN_OPTIONS is not set. Consider setting UBSAN_OPTIONS=symbolize=1:print_stacktrace=1:halt_on_error=1 when running tests") - endif() -endif() -if(sanitizers) - find_package(sanitizer REQUIRED ${sanitizers}) - if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - target_link_libraries(app4triqs_c INTERFACE "-fuse-ld=gold") - endif() +if(ASAN) + find_package(sanitizer REQUIRED "asan") + target_link_libraries(app4triqs_c PUBLIC asan) + install(TARGETS asan EXPORT app4triqs-targets) +endif() +if(UBSAN) + find_package(sanitizer REQUIRED "ubsan") + target_link_libraries(app4triqs_c PUBLIC ubsan) + install(TARGETS ubsan EXPORT app4triqs-targets) endif()