CMakeFindBinUtils.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # if it's the MS C/CXX compiler, search for link
  17. IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
  18. OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
  19. OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
  20. FIND_PROGRAM(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  21. MARK_AS_ADVANCED(CMAKE_LINKER)
  22. # in all other cases search for ar, ranlib, etc.
  23. ELSE("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
  24. OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
  25. OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
  26. FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  27. FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  28. IF(NOT CMAKE_RANLIB)
  29. SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
  30. ENDIF(NOT CMAKE_RANLIB)
  31. FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  32. FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  33. FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  34. FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  35. FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  36. MARK_AS_ADVANCED(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
  37. ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC"
  38. OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC"
  39. OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
  40. # on Apple there really should be install_name_tool
  41. IF(APPLE)
  42. FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
  43. IF(NOT CMAKE_INSTALL_NAME_TOOL)
  44. MESSAGE(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
  45. ENDIF(NOT CMAKE_INSTALL_NAME_TOOL)
  46. MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_TOOL)
  47. ENDIF(APPLE)