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