FindBINUTILS.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the BinUtils development library Once done this will define
  18. #
  19. # BINUTILS_FOUND - system has the BinUtils library BINUTILS_INCLUDE_DIR - the BinUtils include directory BINUTILS_LIBRARIES - The libraries needed
  20. # to use BinUtils
  21. IF (NOT BINUTILS_FOUND)
  22. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  23. IF (${ARCH64BIT} EQUAL 1)
  24. SET (osdir "linux64_gcc4.1.1")
  25. ELSE()
  26. SET (osdir "linux32_gcc4.1.1")
  27. ENDIF()
  28. FIND_PATH (BINUTILS_INCLUDE_DIR NAMES bfd.h PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/include" NO_DEFAULT_PATH)
  29. FIND_LIBRARY (BINUTILS_LIBRARIES NAMES bfd PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
  30. # We also need libiberty - but that is complicated by the fact that some distros ship libibery_pic that you have to use in .so's, while on others libiberty.a is PIC-friendly
  31. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty_pic PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
  32. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
  33. ENDIF()
  34. # if we didn't find in externals, look in system include path
  35. if (USE_NATIVE_LIBRARIES)
  36. FIND_PATH (BINUTILS_INCLUDE_DIR NAMES bfd.h)
  37. FIND_LIBRARY (BINUTILS_LIBRARIES NAMES bfd)
  38. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty_pic)
  39. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty)
  40. endif()
  41. include(FindPackageHandleStandardArgs)
  42. find_package_handle_standard_args(BinUtils DEFAULT_MSG
  43. BINUTILS_LIBRARIES
  44. BINUTILS_INCLUDE_DIR
  45. IBERTY_LIBRARIES
  46. )
  47. IF (BINUTILS_FOUND)
  48. set (BINUTILS_LIBRARIES ${BINUTILS_LIBRARIES} ${IBERTY_LIBRARIES} )
  49. ENDIF()
  50. MARK_AS_ADVANCED(BINUTILS_INCLUDE_DIR BINUTILS_LIBRARIES)
  51. ENDIF()