Starting to change the library used for dwarf parsin.
[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   libdw.h
22   HINTS
23   ${LIBDWARF_INCLUDE_DIRS}
24   PATHS
25   /usr/include
26   /usr/include/elfutils
27   /usr/local/include
28   /opt/local/include
29   /sw/include
30   /usr/local/include/elfutils
31   /opt/local/include/elfutils
32   /sw/include/elfutils
33   ENV CPATH) # PATH and INCLUDE will also work
34
35 find_library (LIBDWARF_LIBRARIES
36   NAMES
37   dw
38   HINTS
39   ${LIBDWARF_LIBRARIES}
40   PATHS
41   /usr/lib
42   /usr/lib64
43   /usr/local/lib
44   /usr/local/lib64
45   /opt/local/lib
46   /opt/local/lib64
47   /sw/lib
48   ENV LIBRARY_PATH   # PATH and LIB will also work
49   ENV LD_LIBRARY_PATH)
50 include (FindPackageHandleStandardArgs)
51
52
53 # handle the QUIETLY and REQUIRED arguments and set LIBDWARF_FOUND to TRUE
54 # if all listed variables are TRUE
55 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDwarf DEFAULT_MSG
56   LIBDWARF_LIBRARIES
57   LIBDWARF_INCLUDE_DIR)
58
59 #mark_as_advanced(LIBDW_INCLUDE_DIR DWARF_INCLUDE_DIR)
60 #mark_as_advanced(LIBDWARF_INCLUDE_DIRS LIBDWARF_LIBRARIES)