CMakeFindBinUtils.cmake 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
  36. OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
  37. OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
  38. FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  39. FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  40. IF(NOT CMAKE_RANLIB)
  41. SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
  42. ENDIF(NOT CMAKE_RANLIB)
  43. FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  44. FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  45. FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  46. FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  47. FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  48. MARK_AS_ADVANCED(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
  49. ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
  50. OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
  51. OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
  52. # on Apple there really should be install_name_tool
  53. IF(APPLE)
  54. FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  55. IF(NOT CMAKE_INSTALL_NAME_TOOL)
  56. MESSAGE(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
  57. ENDIF(NOT CMAKE_INSTALL_NAME_TOOL)
  58. MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_TOOL)
  59. ENDIF(APPLE)