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