1 option(CLANG_INSTALL_SCANBUILD "Install the scan-build tool" ON) 2 3 include(GNUInstallDirs) 4 5 if (WIN32 AND NOT CYGWIN) 6 set(BinFiles 7 scan-build 8 scan-build.bat) 9 set(LibexecFiles 10 ccc-analyzer 11 c++-analyzer 12 ccc-analyzer.bat 13 c++-analyzer.bat) 14 else() 15 set(BinFiles 16 scan-build) 17 set(LibexecFiles 18 ccc-analyzer 19 c++-analyzer) 20 if (APPLE) 21 list(APPEND BinFiles 22 set-xcode-analyzer) 23 endif() 24 endif() 25 26 set(ManPages 27 scan-build.1) 28 29 set(ShareFiles 30 scanview.css 31 sorttable.js) 32 33 34 if(CLANG_INSTALL_SCANBUILD) 35 foreach(BinFile ${BinFiles}) 36 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${BinFile} 37 COMMAND ${CMAKE_COMMAND} -E make_directory 38 ${CMAKE_BINARY_DIR}/bin 39 COMMAND ${CMAKE_COMMAND} -E copy 40 ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile} 41 ${CMAKE_BINARY_DIR}/bin/ 42 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) 43 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) 44 install(PROGRAMS bin/${BinFile} DESTINATION bin) 45 endforeach() 46 47 foreach(LibexecFile ${LibexecFiles}) 48 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/libexec/${LibexecFile} 49 COMMAND ${CMAKE_COMMAND} -E make_directory 50 ${CMAKE_BINARY_DIR}/libexec 51 COMMAND ${CMAKE_COMMAND} -E copy 52 ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile} 53 ${CMAKE_BINARY_DIR}/libexec/ 54 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}) 55 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile}) 56 install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec) 57 endforeach() 58 59 foreach(ManPage ${ManPages}) 60 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage} 61 COMMAND ${CMAKE_COMMAND} -E make_directory 62 ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1 63 COMMAND ${CMAKE_COMMAND} -E copy 64 ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage} 65 ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/ 66 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}) 67 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}) 68 install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 69 endforeach() 70 71 foreach(ShareFile ${ShareFiles}) 72 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile} 73 COMMAND ${CMAKE_COMMAND} -E make_directory 74 ${CMAKE_BINARY_DIR}/share/scan-build 75 COMMAND ${CMAKE_COMMAND} -E copy 76 ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile} 77 ${CMAKE_BINARY_DIR}/share/scan-build/ 78 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile}) 79 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile}) 80 install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build) 81 endforeach() 82 83 add_custom_target(scan-build ALL DEPENDS ${Depends}) 84 set_target_properties(scan-build PROPERTIES FOLDER "Misc") 85 endif() 86