3
0
mirror of https://github.com/triqs/dft_tools synced 2024-07-17 16:33:46 +02:00
dft_tools/share/cmake/Findlibasan_rt.cmake
Nils Wentzell 6aa4eee0f4 [cmake] Fixing usage of ubsan with Minimal RT, some cleaning
- Use UBsan Minimal RT if found
- Prioritize gcc-7 directories over older
- Set UBSan options for c++/python tests
2018-04-24 23:34:14 +02:00

52 lines
1.5 KiB
CMake

# Copyright Nils Wentzell 2018
# Distributed under the GNU GENERAL PUBLIC LICENSE Version 3.0.
# See accompanying file LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt
#
# This cmake find module looks for the LLVM Address Sanitizer Runtime Library
# It sets up : ASAN_RT_LIBRARY
# This module finds the LLVM Address Sanitizer Runtime Library
# latter case skip to the "Boost CMake" section below. For the former
#
# Use this module by invoking find_package with the form::
#
# find_package(libasan_rt [REQUIRED])
#
# Results are reported in::
#
# ASAN_RT_LIBRARY Address Sanitizer Runtime Library
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(name clang_rt.asan-x86_64)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(name asan)
else()
message(FATAL_ERROR "LLVM Address Sanitizer is not available for your compiler")
endif()
find_library(ASAN_RT_LIBRARY
NAMES ${name}
PATHS
ENV LIBRARY_PATH
ENV LD_INCLUDE_PATH
/usr/lib
/usr/local/lib
/usr/lib/gcc/*/7
/usr/lib/gcc/*/*
/usr/lib/clang/*/lib/linux
/usr/lib/llvm-*/lib/clang/*/lib/linux
/usr/local/opt/llvm/lib/clang/*/lib/darwin
)
mark_as_advanced(ASAN_RT_LIBRARY)
# Imported target
add_library(libasan_rt SHARED IMPORTED)
set_property(TARGET libasan_rt PROPERTY IMPORTED_LOCATION ${ASAN_RT_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("Address Sanitizer Runtime Library"
REQUIRED_VARS ASAN_RT_LIBRARY
FAIL_MESSAGE "Address Sanitizer Runtime Libraries not found! Consider installing for additional checks!"
)