Update FindLibIberty to use consistent names and logic with other packages.
[dyninst.git] / cmake / Modules / FindLibIberty.cmake
1 # - Find Iberty
2 # This module finds libiberty.
3 #
4 # It sets the following variables:
5 #  IBERTY_LIBRARIES     - The libiberty library to link against.
6
7 # For Debian <= wheezy, use libiberty_pic.a from binutils-dev
8 # For Debian >= jessie, use libiberty.a from libiberty-dev
9 # For all RHEL/Fedora, use libiberty.a from binutils-devel
10 FIND_LIBRARY( IBERTY_LIBRARIES 
11               NAMES iberty_pic iberty 
12               HINTS ${IBERTY_LIBRARIES}
13               PATHS
14               /usr/lib
15               /usr/lib64
16               /usr/local/lib
17               /usr/local/lib64
18               /opt/local/lib
19               /opt/local/lib64
20               /sw/lib
21               ENV LIBRARY_PATH
22               ENV LD_LIBRARY_PATH
23               )
24
25 IF (IBERTY_LIBRARIES)
26
27    # show which libiberty was found only if not quiet
28    MESSAGE( STATUS "Found libiberty: ${IBERTY_LIBRARIES}")
29
30    SET(IBERTY_FOUND TRUE)
31
32 ELSE (IBERTY_LIBRARIES)
33
34    IF ( IBERTY_FIND_REQUIRED)
35       MESSAGE(FATAL_ERROR "Could not find libiberty. Try to install binutil-devel?")
36    ELSE()
37       MESSAGE(STATUS "Could not find libiberty; downloading binutils and building PIC libiberty.")
38    ENDIF (IBERTY_FIND_REQUIRED)
39
40 ENDIF (IBERTY_LIBRARIES)