FindBINUTILS.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the BinUtils development library Once done this will define
  17. #
  18. # BINUTILS_FOUND - system has the BinUtils library BINUTILS_INCLUDE_DIR - the BinUtils include directory BINUTILS_LIBRARIES - The libraries needed
  19. # to use BinUtils
  20. IF (NOT BINUTILS_FOUND)
  21. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  22. IF (${ARCH64BIT} EQUAL 1)
  23. SET (osdir "linux64_gcc4.1.1")
  24. ELSE()
  25. SET (osdir "linux32_gcc4.1.1")
  26. ENDIF()
  27. FIND_PATH (BINUTILS_INCLUDE_DIR NAMES bfd.h PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/include" NO_DEFAULT_PATH)
  28. FIND_LIBRARY (BINUTILS_LIBRARIES NAMES bfd PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
  29. # 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
  30. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty_pic PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
  31. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
  32. ENDIF()
  33. # if we didn't find in externals, look in system include path
  34. if (USE_NATIVE_LIBRARIES)
  35. FIND_PATH (BINUTILS_INCLUDE_DIR NAMES bfd.h)
  36. FIND_LIBRARY (BINUTILS_LIBRARIES NAMES bfd)
  37. if ( NOT APPLE )
  38. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty_pic)
  39. FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty)
  40. endif ( NOT APPLE )
  41. endif()
  42. include(FindPackageHandleStandardArgs)
  43. if ( NOT APPLE )
  44. find_package_handle_standard_args(BinUtils DEFAULT_MSG
  45. BINUTILS_LIBRARIES
  46. BINUTILS_INCLUDE_DIR
  47. IBERTY_LIBRARIES
  48. )
  49. IF (BINUTILS_FOUND)
  50. set (BINUTILS_LIBRARIES ${BINUTILS_LIBRARIES} ${IBERTY_LIBRARIES} )
  51. ENDIF()
  52. else ( NOT APPLE )
  53. find_package_handle_standard_args(BinUtils DEFAULT_MSG
  54. BINUTILS_LIBRARIES
  55. BINUTILS_INCLUDE_DIR
  56. )
  57. IF (BINUTILS_FOUND)
  58. set (BINUTILS_LIBRARIES ${BINUTILS_LIBRARIES} )
  59. ENDIF()
  60. endif ( NOT APPLE )
  61. MARK_AS_ADVANCED(BINUTILS_INCLUDE_DIR BINUTILS_LIBRARIES)
  62. ENDIF()