2018-03-25 19:00:54 +02:00
|
|
|
# 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")
|
2018-11-21 22:52:55 +01:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
set(name clang_rt.asan_osx_dynamic)
|
2018-11-27 00:33:03 +01:00
|
|
|
else()
|
2018-11-21 22:52:55 +01:00
|
|
|
set(name clang_rt.asan-x86_64)
|
|
|
|
endif()
|
2018-03-25 19:00:54 +02:00
|
|
|
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
|
2018-11-20 23:53:10 +01:00
|
|
|
ENV LD_LIBRARY_PATH
|
2018-03-25 19:00:54 +02:00
|
|
|
/usr/lib
|
|
|
|
/usr/local/lib
|
2018-04-24 23:31:52 +02:00
|
|
|
/usr/lib/gcc/*/7
|
2018-03-25 19:00:54 +02:00
|
|
|
/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!"
|
|
|
|
)
|