105 lines · plain
1option(CLANG_INSTALL_SCANBUILD "Install the scan-build tool" ON)2 3include(GNUInstallDirs)4 5if (WIN32 AND NOT CYGWIN)6 set(BinFiles7 scan-build8 scan-build.bat9 )10 set(LibexecFiles11 ccc-analyzer12 c++-analyzer13 ccc-analyzer.bat14 c++-analyzer.bat15 )16else()17 set(BinFiles18 scan-build19 )20 set(LibexecFiles21 ccc-analyzer22 c++-analyzer23 )24 if (APPLE)25 list(APPEND BinFiles26 set-xcode-analyzer27 )28 endif()29endif()30 31set(ManPages32 scan-build.1)33 34set(ShareFiles35 scanview.css36 sorttable.js)37 38 39if(CLANG_INSTALL_SCANBUILD)40 foreach(BinFile ${BinFiles})41 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${BinFile}42 COMMAND ${CMAKE_COMMAND} -E make_directory43 ${CMAKE_BINARY_DIR}/bin44 COMMAND ${CMAKE_COMMAND} -E copy45 ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}46 ${CMAKE_BINARY_DIR}/bin/47 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})48 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})49 install(PROGRAMS bin/${BinFile}50 DESTINATION "${CMAKE_INSTALL_BINDIR}"51 COMPONENT scan-build)52 endforeach()53 54 foreach(LibexecFile ${LibexecFiles})55 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/libexec/${LibexecFile}56 COMMAND ${CMAKE_COMMAND} -E make_directory57 ${CMAKE_BINARY_DIR}/libexec58 COMMAND ${CMAKE_COMMAND} -E copy59 ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}60 ${CMAKE_BINARY_DIR}/libexec/61 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})62 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})63 install(PROGRAMS libexec/${LibexecFile}64 DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}"65 COMPONENT scan-build)66 endforeach()67 68 foreach(ManPage ${ManPages})69 add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}"70 COMMAND ${CMAKE_COMMAND} -E make_directory71 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1"72 COMMAND ${CMAKE_COMMAND} -E copy73 "${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}"74 "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/"75 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})76 list(APPEND Depends "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}")77 install(FILES man/${ManPage}78 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"79 COMPONENT scan-build)80 endforeach()81 82 foreach(ShareFile ${ShareFiles})83 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile}84 COMMAND ${CMAKE_COMMAND} -E make_directory85 ${CMAKE_BINARY_DIR}/share/scan-build86 COMMAND ${CMAKE_COMMAND} -E copy87 ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile}88 ${CMAKE_BINARY_DIR}/share/scan-build/89 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})90 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})91 install(FILES share/scan-build/${ShareFile}92 DESTINATION "${CMAKE_INSTALL_DATADIR}/scan-build"93 COMPONENT scan-build)94 endforeach()95 96 add_custom_target(scan-build ALL DEPENDS ${Depends})97 set_target_properties(scan-build PROPERTIES FOLDER "Misc")98 99 if(NOT LLVM_ENABLE_IDE)100 add_llvm_install_targets("install-scan-build"101 DEPENDS scan-build102 COMPONENT scan-build)103 endif()104endif()105