Warning, /sdk/elf-dissector/cmake/FindIberty.cmake is written in an unsupported language. File is not indexed.
0001 # TODO turn this in a FindBinutils with components 0002 include(CheckCSourceCompiles) 0003 include(FindPackageHandleStandardArgs) 0004 0005 find_path(Iberty_INCLUDE_DIR demangle.h PATH_SUFFIXES libiberty) 0006 find_library(Iberty_LIBRARY NAMES iberty) 0007 0008 find_package_handle_standard_args(Iberty DEFAULT_MSG Iberty_LIBRARY Iberty_INCLUDE_DIR) 0009 0010 # TODO improve this version check 0011 set(Binutils_VERSION_MAJOR 2) 0012 set(Binutils_VERSION_MINOR 22) 0013 0014 set(_old_requires ${CMAKE_REQUIRED_INCLUDES}) 0015 list(APPEND CMAKE_REQUIRED_INCLUDES ${Iberty_INCLUDE_DIR}) 0016 0017 check_c_source_compiles(" 0018 #include <demangle.h> 0019 int main(int argc, char **argv) { 0020 return DEMANGLE_COMPONENT_INITIALIZER_LIST; 0021 }" 0022 Binutils_HAVE_DEMANGLE_COMPONENT_INITIALIZER_LIST 0023 ) 0024 if(Binutils_HAVE_DEMANGLE_COMPONENT_INITIALIZER_LIST) 0025 set(Binutils_VERSION_MINOR 23) 0026 endif() 0027 0028 check_c_source_compiles(" 0029 #include <demangle.h> 0030 int main(int argc, char **argv) { 0031 return DEMANGLE_COMPONENT_REFERENCE_THIS; 0032 }" 0033 Binutils_HAVE_DEMANGLE_COMPONENT_REFERENCE_THIS 0034 ) 0035 if(Binutils_HAVE_DEMANGLE_COMPONENT_REFERENCE_THIS) 0036 set(Binutils_VERSION_MINOR 24) 0037 endif() 0038 0039 if(IBERTY_FOUND AND NOT TARGET Binutils::Iberty) 0040 add_library(Binutils::Iberty UNKNOWN IMPORTED) 0041 set_target_properties(Binutils::Iberty PROPERTIES 0042 IMPORTED_LOCATION "${Iberty_LIBRARY}" 0043 INTERFACE_INCLUDE_DIRECTORIES "${Iberty_INCLUDE_DIR}" 0044 ) 0045 endif() 0046 0047 mark_as_advanced(Iberty_LIBRARY Iberty_INCLUDE_DIR) 0048 0049 0050 find_path(Opcodes_INCLUDE_DIR dis-asm.h) 0051 find_library(Opcodes_LIBRARY NAMES opcodes) 0052 0053 find_package_handle_standard_args(Opcodes DEFAULT_MSG Opcodes_INCLUDE_DIR Opcodes_LIBRARY) 0054 0055 if(OPCODES_FOUND AND NOT TARGET Binutils::Opcodes) 0056 add_library(Binutils::Opcodes UNKNOWN IMPORTED) 0057 set_target_properties(Binutils::Opcodes PROPERTIES 0058 IMPORTED_LOCATION "${Opcodes_LIBRARY}" 0059 INTERFACE_INCLUDE_DIRECTORIES "${Opcodes_INCLUDE_DIR}" 0060 ) 0061 endif() 0062 0063 0064 set(CMAKE_REQUIRED_LIBRARIES ${Opcodes_LIBRARY}) 0065 check_c_source_compiles(" 0066 #include <dis-asm.h> 0067 int main(int argc, char **argv) { 0068 disassembler_ftype ftype = print_insn_i386; 0069 return 0; 0070 }" 0071 Binutils_HAVE_PRINT_INSN_I386 0072 ) 0073 if(NOT Binutils_HAVE_PRINT_INSN_I386) 0074 set(Binutils_VERSION_MINOR 29) 0075 endif() 0076 0077 mark_as_advanced(Opcodes_LIBRARY Opcodes_INCLUDE_DIR) 0078 0079 check_c_source_compiles(" 0080 #include <demangle.h> 0081 int main(int argc, char **argv) { 0082 return DEMANGLE_COMPONENT_TPARM_OBJ; 0083 }" 0084 Binutils_HAVE_DEMANGLE_COMPONENT_TPARM_OBJ 0085 ) 0086 if(Binutils_HAVE_DEMANGLE_COMPONENT_TPARM_OBJ) 0087 set(Binutils_VERSION_MINOR 32) 0088 endif() 0089 0090 # we don't really care about that particular define, but about a behavior 0091 # difference in demangling, but that is much harder to check for here 0092 check_c_source_compiles(" 0093 #include <ctf.h> 0094 int main(int argc, char **argv) { 0095 return CTF_F_NEWFUNCINFO; 0096 }" 0097 Binutils_HAVE_CTF_F_NEWFUNCINFO 0098 ) 0099 if(Binutils_HAVE_CTF_F_NEWFUNCINFO) 0100 set(Binutils_VERSION_MINOR 36) 0101 endif() 0102 0103 check_c_source_compiles(" 0104 #include <dis-asm.h> 0105 int main(int, char**) { 0106 init_disassemble_info(NULL, NULL, NULL, NULL); 0107 return 0; 0108 }" 0109 Binutils_HAVE_4ARG_INTI_DISASSEMBLE_INFO 0110 ) 0111 if (Binutils_HAVE_4ARG_INTI_DISASSEMBLE_INFO) 0112 set(Binutils_VERSION_MINOR 39) 0113 endif() 0114 0115 if(TARGET Binutils::Iberty) 0116 target_link_libraries(Binutils::Iberty INTERFACE Binutils::Opcodes) 0117 endif() 0118 if(TARGET Binutils::Opcodes) 0119 target_link_libraries(Binutils::Opcodes INTERFACE Binutils::Iberty) 0120 endif() 0121 0122 include(FeatureSummary) 0123 set_package_properties(binutils-devel PROPERTIES URL https://www.gcc.org/ 0124 DESCRIPTION "Development files of binutils.") 0125 0126 set(CMAKE_REQUIRED_INCLUDES ${_old_requires})