Clang-FindBinUtils.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "")
  2. message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set")
  3. endif()
  4. # Debian:
  5. # * /usr/bin/llvm-ar-4.0
  6. # * /usr/bin/llvm-ranlib-4.0
  7. string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y
  8. "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}")
  9. # Try to find tools in the same directory as Clang itself
  10. get_filename_component(__clang_hint_1 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" REALPATH)
  11. get_filename_component(__clang_hint_1 "${__clang_hint_1}" DIRECTORY)
  12. get_filename_component(__clang_hint_2 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY)
  13. set(__clang_hints ${__clang_hint_1} ${__clang_hint_2})
  14. # http://manpages.ubuntu.com/manpages/precise/en/man1/llvm-ar.1.html
  15. find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES
  16. "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar-${__version_x_y}"
  17. "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar"
  18. HINTS ${__clang_hints}
  19. DOC "LLVM archiver"
  20. )
  21. mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR)
  22. # http://manpages.ubuntu.com/manpages/precise/en/man1/llvm-ranlib.1.html
  23. find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES
  24. "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib-${__version_x_y}"
  25. "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib"
  26. HINTS ${__clang_hints}
  27. DOC "Generate index for LLVM archive"
  28. )
  29. mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB)