Adapting Object-elf.C
[dyninst.git] / cmake / Modules / FindLibDwarf.cmake
1 # - Try to find libdwarf
2 # Once done this will define
3 #
4 #  LIBDWARF_FOUND - system has libdwarf
5 #  LIBDWARF_INCLUDE_DIRS - the libdwarf include directory
6 #  LIBDWARF_LIBRARIES - Link these to use libdwarf
7 #  LIBDWARF_DEFINITIONS - Compiler switches required for using libdwarf
8 #
9
10 # Locate libelf library at first
11 #if (NOT LIBELF_FOUND)
12 #   find_package (LibElf REQUIRED)
13 #endif (NOT LIBELF_FOUND)
14
15 if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS)
16   set (LibDwarf_FIND_QUIETLY TRUE)
17 endif (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS)
18
19 find_path (LIBDWARF_INCLUDE_DIR
20   NAMES
21   elfutils/libdw.h
22   HINTS
23   ${LIBDWARF_INCLUDE_DIRS}
24   PATHS
25   /usr/include
26   /usr/local/include
27   /opt/local/include
28   /sw/include
29   ENV CPATH) # PATH and INCLUDE will also work
30
31 find_library (LIBDWARF_LIBRARIES
32   NAMES
33   dw
34   HINTS
35   ${LIBDWARF_LIBRARIES}
36   PATHS
37   /usr/lib
38   /usr/lib64
39   /usr/local/lib
40   /usr/local/lib64
41   /opt/local/lib
42   /opt/local/lib64
43   /sw/lib
44   ENV LIBRARY_PATH   # PATH and LIB will also work
45   ENV LD_LIBRARY_PATH)
46 include (FindPackageHandleStandardArgs)
47
48
49 # handle the QUIETLY and REQUIRED arguments and set LIBDWARF_FOUND to TRUE
50 # if all listed variables are TRUE
51 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDwarf DEFAULT_MSG
52   LIBDWARF_LIBRARIES
53   LIBDWARF_INCLUDE_DIR)
54
55 #mark_as_advanced(LIBDW_INCLUDE_DIR DWARF_INCLUDE_DIR)
56 #mark_as_advanced(LIBDWARF_INCLUDE_DIRS LIBDWARF_LIBRARIES)