cmake: find libiberty headers via cmake module

The libiberty headers moved from /usr/include (and a part of binutils-dev)
to /usr/include/libiberty (libiberty-dev) between Ubuntu 13.10 and 14.04,
which made a proper cmake search module necessary.  Searching still
continues working well on Debian 7.

Change-Id: I324e5ccb847e4664442d6fa7d7a027705a4f0587
This commit is contained in:
Horst Schirmeier
2014-03-30 18:16:13 +02:00
committed by Horst Schirmeier
parent da839c9765
commit 9113d7c2fa
3 changed files with 46 additions and 8 deletions

42
cmake/FindLibIberty.cmake Normal file
View File

@ -0,0 +1,42 @@
# - FindLibIberty.cmake
# This module can find libiberty on both Debian 7 and Ubuntu 14.04
# (The libiberty headers moved from /usr/include to /usr/include/libiberty
# between Ubuntu 13.10 and 14.04, which made this search module necessary.)
#
# The following variables will be defined for your use:
#
# LibIberty_FOUND - TRUE if both library and headers were found
# LibIberty_INCLUDE_DIRS - Include directories
# LibIberty_LIBRARIES - Library path
# set(LibIberty_PREFER_DYNAMIC True) if you want to prefer the dynamic library
if(LibIberty_PREFER_DYNAMIC)
set(LibIberty_SEARCHORDER libiberty.so libiberty.a)
else()
set(LibIberty_SEARCHORDER libiberty.a libiberty.so)
endif()
find_library(LibIberty_LIBRARIES NAMES ${LibIberty_SEARCHORDER})
find_path(LibIberty_INCLUDE_DIRS libiberty.h
PATHS
/usr/include /usr/include/libiberty
/usr/local/include /usr/local/include/libiberty
DOC "libiberty include directory containing libiberty.h")
if(LibIberty_INCLUDE_DIRS AND LibIberty_LIBRARIES)
set(LibIberty_FOUND TRUE)
endif()
if(LibIberty_FOUND)
if(NOT LibIberty_FIND_QUIETLY)
MESSAGE(STATUS "Found libiberty: ${LibIberty_LIBRARIES}")
endif()
else()
if(LibIberty_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libiberty: install binutils-dev or libiberty-dev")
else()
MESSAGE(STATUS "libiberty not found")
endif()
endif()

View File

@ -13,7 +13,7 @@ Required for Fail*:
- protobuf-compiler - protobuf-compiler
- cmake 2.8.2 (2.8.11 preferred) - cmake 2.8.2 (2.8.11 preferred)
- cmake-curses-gui - cmake-curses-gui
- binutils-dev - binutils-dev, on newer systems libiberty-dev
- AspectC++ (ag++, ac++): AspectC++ 1.1 or newer is known to work and can be - AspectC++ (ag++, ac++): AspectC++ 1.1 or newer is known to work and can be
obtained from <http://www.aspectc.org>; nightlies can be downloaded from obtained from <http://www.aspectc.org>; nightlies can be downloaded from
<http://akut.aspectc.org>. Make sure you use the 64-bit version if running <http://akut.aspectc.org>. Make sure you use the 64-bit version if running

View File

@ -43,12 +43,8 @@ include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS})
# libiberty required by Demangler.cc: # libiberty required by Demangler.cc:
find_library(LIB_IBERTY iberty) find_package(LibIberty REQUIRED)
mark_as_advanced(LIB_IBERTY) include_directories(${LibIberty_INCLUDE_DIRS})
if(${LIB_IBERTY} STREQUAL LIB_IBERTY-NOTFOUND)
message(FATAL_ERROR "libiberty not found. Try installing binutils-dev: [ sudo aptitude install binutils-dev ]")
endif()
# libz required by gzstream # libz required by gzstream
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
@ -74,7 +70,7 @@ mark_as_advanced(FAIL_OBJDUMP)
add_library(fail-util ${SRCS}) add_library(fail-util ${SRCS})
add_dependencies(fail-util fail-comm) add_dependencies(fail-util fail-comm)
target_link_libraries(fail-util fail-comm) target_link_libraries(fail-util fail-comm)
target_link_libraries(fail-util ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${LIB_IBERTY} ${ZLIB_LIBRARIES} ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES}) target_link_libraries(fail-util ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${LibIberty_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.3 preferred, for 3.1 and 3.2 read doc/how-to-build.txt)" OFF) option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.3 preferred, for 3.1 and 3.2 read doc/how-to-build.txt)" OFF)
if (BUILD_LLVM_DISASSEMBLER) if (BUILD_LLVM_DISASSEMBLER)