Warning, /pim/kube/cmake/modules/FindLibBfd.cmake is written in an unsupported language. File is not indexed.
0001 # - Try to find libbfd 0002 # Once done this will define 0003 # 0004 # LIBBFD_FOUND - system has libbfd 0005 # LIBBFD_INCLUDE_DIRS - the libbfd include directory 0006 # LIBBFD_LIBRARIES - Link these to use libbfd 0007 # LIBBFD_DEFINITIONS - Compiler switches required for using libbfd 0008 # LIBIBERTY_LIBRARIES - libiberty static library (for static compilation) 0009 # LIBZ_LIBRARIES - libz static library (for static compilation) 0010 0011 #if (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS) 0012 # set (LibBpf_FIND_QUIETLY TRUE) 0013 #endif (LIBBFD_LIBRARIES AND LIBBFD_INCLUDE_DIRS) 0014 0015 find_path (LIBBFD_INCLUDE_DIRS 0016 NAMES 0017 bfd.h 0018 PATHS 0019 ENV CPATH) 0020 0021 find_library (LIBBFD_LIBRARIES 0022 NAMES 0023 bfd 0024 PATHS 0025 ENV LIBRARY_PATH 0026 ENV LD_LIBRARY_PATH) 0027 0028 # libbfd.so is statically linked with libiberty.a but libbfd.a 0029 # is not. So if we do a static bpftrace build, we must link in 0030 # libiberty.a 0031 find_library (LIBIBERTY_LIBRARIES 0032 NAMES 0033 libiberty.a 0034 PATHS 0035 ENV LIBRARY_PATH 0036 ENV LD_LIBRARY_PATH) 0037 0038 include (FindPackageHandleStandardArgs) 0039 0040 0041 # handle the QUIETLY and REQUIRED arguments and set LIBBFD_FOUND to TRUE if all listed variables are TRUE 0042 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBfd "Please install the libbfd development package" 0043 LIBBFD_LIBRARIES 0044 LIBBFD_INCLUDE_DIRS) 0045 0046 mark_as_advanced(LIBBFD_INCLUDE_DIRS LIBBFD_LIBRARIES) 0047 0048 if(${LIBBFD_FOUND}) 0049 find_package(LibOpcodes) 0050 SET(CMAKE_REQUIRED_LIBRARIES ${LIBBFD_LIBRARIES} ${LIBOPCODES_LIBRARIES}) 0051 # libbfd.a is not statically linked with libiberty.a or libz.a so we must manually 0052 # do it. Furthermore, libbfd uses some libc symbols that we must manually 0053 # link against if we're not using static libc (which includes such symbols). 0054 if(STATIC_LINKING) 0055 find_package(LibZ) 0056 list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBIBERTY_LIBRARIES} ${LIBZ_LIBRARIES}) 0057 if(NOT STATIC_LIBC) 0058 set(CMAKE_REQUIRED_FLAGS 0059 "-Wl,--start-group -Wl,-Bdynamic -Wl,-Bdynamic -lpthread -Wl,-Bdynamic -ldl") 0060 endif() 0061 endif() 0062 INCLUDE(CheckCXXSourceCompiles) 0063 CHECK_CXX_SOURCE_COMPILES(" 0064 #include <string.h> 0065 // See comment in bfd-disasm.cpp for why this needs to exist 0066 #define PACKAGE \"bpftrace-test\" 0067 #include <bfd.h> 0068 #include <dis-asm.h> 0069 int main(void) { 0070 bfd *abfd = bfd_openr(NULL, NULL); 0071 0072 disassembler(bfd_get_arch(abfd), 0073 bfd_big_endian(abfd), 0074 bfd_get_mach(abfd), 0075 abfd); 0076 return 0; 0077 }" LIBBFD_DISASM_FOUR_ARGS_SIGNATURE) 0078 SET(CMAKE_REQUIRED_LIBRARIES) 0079 endif()