Skip to content

Commit

Permalink
Issue SimonKagstrom#83: build: Look for bintuils to make it optional
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKagstrom committed Apr 9, 2015
1 parent fd52edb commit 86cac29
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 8 deletions.
85 changes: 85 additions & 0 deletions cmake/FindBfd.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# - Try to find libbfd
# Once done this will define
#
# LIBBFD_FOUND - system has libbfd
# LIBBFD_INCLUDE_DIRS - the libbfd include directory
# LIBBFD_LIBRARIES - Link these to use libbfd
# LIBBFD_DEFINITIONS - Compiler switches required for using libbfd
#
# Based on:
#
# Copyright (c) 2008 Bernhard Walle <[email protected]>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


if (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS)
set (LIBBFD_FIND_QUIETLY TRUE)
endif (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS)

find_path (LIBBFD_INCLUDE_DIRS
NAMES
bfd.h
dis-asm.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/opt/include
ENV CPATH)

# Ugly, yes ugly...
find_library (LIBBFD_BFD_LIBRARY
NAMES
bfd
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/opt/usr/lib64
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

find_library (LIBBFD_IBERTY_LIBRARY
NAMES
iberty
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/opt/usr/lib64
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

find_library (LIBBFD_OPCODES_LIBRARY
NAMES
opcodes
PATHS
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64
/opt/local/lib
/opt/usr/lib64
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)


include (FindPackageHandleStandardArgs)


# handle the QUIETLY and REQUIRED arguments and set LIBBFD_FOUND to TRUE if all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBBFD DEFAULT_MSG
LIBBFD_BFD_LIBRARY
LIBBFD_IBERTY_LIBRARY
LIBBFD_OPCODES_LIBRARY
LIBBFD_INCLUDE_DIRS)

mark_as_advanced(LIBBFD_INCLUDE_DIRS LIBBFD_LIBRARIES)
19 changes: 11 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/../../cmake)
find_package (LibElf REQUIRED)
find_package (Elfutils REQUIRED)
find_package (Bfd)

include(TargetArch)
target_architecture(CMAKE_TARGET_ARCHITECTURES)
Expand Down Expand Up @@ -32,14 +33,16 @@ set (ADDRESS_VERIFIER_SRCS
)

if("${CMAKE_TARGET_ARCHITECTURES}" STREQUAL "i386" OR "${CMAKE_TARGET_ARCHITECTURES}" STREQUAL "x86_64")
set (ADDRESS_VERIFIER_SRCS
parsers/bfd-address-verifier.cc
)
set (ADDRESS_VERIFIER_LIBRARIES
bfd
iberty
opcodes
)
if(LIBBFD_FOUND)
set (ADDRESS_VERIFIER_SRCS
parsers/bfd-address-verifier.cc
)
set (ADDRESS_VERIFIER_LIBRARIES
${LIBBFD_BFD_LIBRARY}
${LIBBFD_IBERTY_LIBRARY}
${LIBBFD_OPCODES_LIBRARY}
)
endif()
endif()

set (LINUX_SRCS
Expand Down

0 comments on commit 86cac29

Please sign in to comment.