cyy | a6a3a78 | 2019-02-07 22:27:33 +0800 | [diff] [blame] | 1 | # - Try to find Clang tools |
| 2 | # |
| 3 | # The following are set after configuration is done: |
| 4 | # clang-tidy_FOUND |
| 5 | # ClangTools::clang-tidy |
| 6 | # clang-apply-replacements_FOUND |
| 7 | # ClangTools::clang-apply-replacements |
| 8 | # run-clang-tidy_FOUND |
| 9 | # ClangTools::run-clang-tidy |
| 10 | |
| 11 | include_guard() |
| 12 | include(FindPackageHandleStandardArgs) |
| 13 | |
| 14 | foreach(program_name IN ITEMS clang-tidy clang-apply-replacements) |
| 15 | find_program(${program_name}_BINARY NAMES ${program_name}-devel ${program_name}-8 ${program_name} PATH_SUFFIXES "LLVM/bin") |
| 16 | find_package_handle_standard_args(${program_name} DEFAULT_MSG ${program_name}_BINARY) |
| 17 | if(${program_name}_FOUND AND NOT TARGET ClangTools::${program_name}) |
| 18 | add_executable(ClangTools::${program_name} IMPORTED) |
| 19 | set_property(TARGET ClangTools::${program_name} PROPERTY IMPORTED_LOCATION "${${program_name}_BINARY}") |
| 20 | endif() |
| 21 | endforeach() |
| 22 | |
| 23 | find_program(run-clang-tidy_BINARY NAMES run-clang-tidy run-clang-tidy.py PATH_SUFFIXES "LLVM/bin" "llvm-devel/share/clang") |
| 24 | find_package_handle_standard_args(run-clang-tidy DEFAULT_MSG run-clang-tidy_BINARY) |
| 25 | if(run-clang-tidy_FOUND AND NOT TARGET ClangTools::run-clang-tidy) |
| 26 | add_executable(ClangTools::run-clang-tidy IMPORTED) |
| 27 | set_property(TARGET ClangTools::run-clang-tidy PROPERTY IMPORTED_LOCATION "${run-clang-tidy_BINARY}") |
| 28 | endif() |