CMakeFindBinUtils.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # search for additional tools required for C/C++ (and other languages ?)
  2. #
  3. # If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used
  4. # as prefix for the tools (e.g. arm-elf-gcc etc.)
  5. # If the cmake variable _CMAKE_TOOLCHAIN_LOCATION is set, the compiler is
  6. # searched only there. The other tools are at first searched there, then
  7. # also in the default locations.
  8. #
  9. # Sets the following variables:
  10. # CMAKE_AR
  11. # CMAKE_RANLIB
  12. # CMAKE_LINKER
  13. # CMAKE_STRIP
  14. # CMAKE_INSTALL_NAME_TOOL
  15. # on UNIX, cygwin and mingw
  16. #=============================================================================
  17. # Copyright 2007-2009 Kitware, Inc.
  18. #
  19. # Distributed under the OSI-approved BSD License (the "License");
  20. # see accompanying file Copyright.txt for details.
  21. #
  22. # This software is distributed WITHOUT ANY WARRANTY; without even the
  23. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. # See the License for more information.
  25. #=============================================================================
  26. # (To distribute this file outside of CMake, substitute the full
  27. # License text for the above reference.)
  28. # if it's the MS C/CXX compiler, search for link
  29. if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
  30. OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
  31. OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
  32. find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  33. mark_as_advanced(CMAKE_LINKER)
  34. # in all other cases search for ar, ranlib, etc.
  35. else()
  36. find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  37. find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  38. if(NOT CMAKE_RANLIB)
  39. set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
  40. endif()
  41. find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  42. find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  43. find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  44. find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  45. find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  46. mark_as_advanced(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
  47. endif()
  48. # on Apple there really should be install_name_tool
  49. if(APPLE)
  50. find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  51. if(NOT CMAKE_INSTALL_NAME_TOOL)
  52. message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
  53. endif()
  54. mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
  55. endif()