Debian Codegraph @

cmake/FindLibunwind.cmake

raw
1 # - Try to find libunwind
2 # Once done this will define
3 #
4 # LIBUNWIND_FOUND - system has libunwind
5 # LIBUNWIND_INCLUDE_DIR - the libunwind include directory
6 # LIBUNWIND_LIBRARIES - Link these to use libunwind
7 # LIBUNWIND_DEFINITIONS - Compiler switches required for using libunwind
8
9 # Copyright (c) 2006, Alexander Dymo, <[email protected]>
10 #
11 # Redistribution and use is allowed according to the terms of the BSD license.
12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
13
14 find_path(LIBUNWIND_INCLUDE_DIR libunwind.h
15 /usr/include
16 /usr/local/include
17 )
18
19 find_library(LIBUNWIND_LIBRARIES NAMES unwind )
20 if(NOT LIBUNWIND_LIBRARIES STREQUAL "LIBUNWIND_LIBRARIES-NOTFOUND")
21 if (CMAKE_COMPILER_IS_GNUCC)
22 set(LIBUNWIND_LIBRARIES "gcc_eh;${LIBUNWIND_LIBRARIES}")
23 endif()
24 endif()
25
26 # some versions of libunwind need liblzma, and we don't use pkg-config
27 # so we just look whether liblzma is installed, and add it if it is.
28 # It might not be actually needed, but doesn't hurt if it is not.
29 # We don't need any headers, just the lib, as it's privately needed.
30 message(STATUS "looking for liblzma")
31 find_library(LIBLZMA_LIBRARIES lzma )
32 if(NOT LIBLZMA_LIBRARIES STREQUAL "LIBLZMA_LIBRARIES-NOTFOUND")
33 message(STATUS "liblzma found")
34 set(LIBUNWIND_LIBRARIES "${LIBUNWIND_LIBRARIES};${LIBLZMA_LIBRARIES}")
35 endif()
36
37 include(FindPackageHandleStandardArgs)
38 find_package_handle_standard_args(Libunwind "Could not find libunwind" LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARIES)
39 # show the LIBUNWIND_INCLUDE_DIR and LIBUNWIND_LIBRARIES variables only in the advanced view
40 mark_as_advanced(LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARIES )
41