blob: 78c243d8e0d6535677b83565ae954227e3ad44f9 [file] [log] [blame]
Jonathan Roelofse9614322015-11-09 16:12:56 +00001option(CLANG_INSTALL_SCANBUILD "Install the scan-build tool" ON)
2
Chris Bieneman0502e982015-11-20 18:49:02 +00003include(GNUInstallDirs)
4
Jonathan Roelofse9614322015-11-09 16:12:56 +00005if (WIN32 AND NOT CYGWIN)
6 set(BinFiles
7 scan-build.bat)
8 set(LibexecFiles
9 ccc-analyzer.bat
10 c++-analyzer.bat)
11else()
12 set(BinFiles
13 scan-build)
14 set(LibexecFiles
15 ccc-analyzer
16 c++-analyzer)
17 if (APPLE)
Jonathan Roelofs1ff9c632015-11-10 22:48:11 +000018 list(APPEND BinFiles
19 set-xcode-analyzer)
Jonathan Roelofse9614322015-11-09 16:12:56 +000020 endif()
21endif()
22
23set(ManPages
24 scan-build.1)
25
Jonathan Roelofs2ec2acb2015-11-13 00:32:54 +000026set(ShareFiles
Jonathan Roelofse9614322015-11-09 16:12:56 +000027 scanview.css
28 sorttable.js)
29
30
31if(CLANG_INSTALL_SCANBUILD)
32 foreach(BinFile ${BinFiles})
Jonathan Roelofs467ab052015-11-10 22:38:59 +000033 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${BinFile}
Jonathan Roelofse9614322015-11-09 16:12:56 +000034 COMMAND ${CMAKE_COMMAND} -E make_directory
35 ${CMAKE_BINARY_DIR}/bin
36 COMMAND ${CMAKE_COMMAND} -E copy
Jonathan Roelofs814aa252015-11-13 20:34:15 +000037 ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}
Jonathan Roelofs2a439a12015-11-10 20:01:22 +000038 ${CMAKE_BINARY_DIR}/bin/
Jonathan Roelofs814aa252015-11-13 20:34:15 +000039 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
Jonathan Roelofs1ff9c632015-11-10 22:48:11 +000040 list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
Jonathan Roelofs814aa252015-11-13 20:34:15 +000041 install(PROGRAMS bin/${BinFile} DESTINATION bin)
Jonathan Roelofse9614322015-11-09 16:12:56 +000042 endforeach()
43
44 foreach(LibexecFile ${LibexecFiles})
Jonathan Roelofs467ab052015-11-10 22:38:59 +000045 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/libexec/${LibexecFile}
Jonathan Roelofse9614322015-11-09 16:12:56 +000046 COMMAND ${CMAKE_COMMAND} -E make_directory
47 ${CMAKE_BINARY_DIR}/libexec
48 COMMAND ${CMAKE_COMMAND} -E copy
Jonathan Roelofs814aa252015-11-13 20:34:15 +000049 ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}
Jonathan Roelofs2a439a12015-11-10 20:01:22 +000050 ${CMAKE_BINARY_DIR}/libexec/
Jonathan Roelofs814aa252015-11-13 20:34:15 +000051 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile})
Jonathan Roelofs1ff9c632015-11-10 22:48:11 +000052 list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile})
Jonathan Roelofs814aa252015-11-13 20:34:15 +000053 install(PROGRAMS libexec/${LibexecFile} DESTINATION libexec)
Jonathan Roelofse9614322015-11-09 16:12:56 +000054 endforeach()
55
56 foreach(ManPage ${ManPages})
Chris Bieneman0502e982015-11-20 18:49:02 +000057 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage}
Jonathan Roelofse9614322015-11-09 16:12:56 +000058 COMMAND ${CMAKE_COMMAND} -E make_directory
Chris Bieneman0502e982015-11-20 18:49:02 +000059 ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1
Jonathan Roelofse9614322015-11-09 16:12:56 +000060 COMMAND ${CMAKE_COMMAND} -E copy
Jonathan Roelofs814aa252015-11-13 20:34:15 +000061 ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage}
Chris Bieneman0502e982015-11-20 18:49:02 +000062 ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/
Jonathan Roelofs814aa252015-11-13 20:34:15 +000063 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/man/${ManPage})
Chris Bieneman0502e982015-11-20 18:49:02 +000064 list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_MANDIR}/man1/${ManPage})
65 install(PROGRAMS man/${ManPage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
Jonathan Roelofse9614322015-11-09 16:12:56 +000066 endforeach()
67
Jonathan Roelofs2ec2acb2015-11-13 00:32:54 +000068 foreach(ShareFile ${ShareFiles})
Jonathan Roelofs80df3d22015-11-13 19:56:07 +000069 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile}
Jonathan Roelofse9614322015-11-09 16:12:56 +000070 COMMAND ${CMAKE_COMMAND} -E make_directory
Jonathan Roelofs80df3d22015-11-13 19:56:07 +000071 ${CMAKE_BINARY_DIR}/share/scan-build
Jonathan Roelofse9614322015-11-09 16:12:56 +000072 COMMAND ${CMAKE_COMMAND} -E copy
Jonathan Roelofs814aa252015-11-13 20:34:15 +000073 ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile}
Jonathan Roelofs80df3d22015-11-13 19:56:07 +000074 ${CMAKE_BINARY_DIR}/share/scan-build/
Jonathan Roelofs814aa252015-11-13 20:34:15 +000075 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/share/scan-build/${ShareFile})
Jonathan Roelofs80df3d22015-11-13 19:56:07 +000076 list(APPEND Depends ${CMAKE_BINARY_DIR}/share/scan-build/${ShareFile})
Jonathan Roelofs814aa252015-11-13 20:34:15 +000077 install(FILES share/scan-build/${ShareFile} DESTINATION share/scan-build)
Jonathan Roelofse9614322015-11-09 16:12:56 +000078 endforeach()
Jonathan Roelofs467ab052015-11-10 22:38:59 +000079
80 add_custom_target(scan-build ALL DEPENDS ${Depends})
Aaron Ballman8f3f6342015-11-11 18:13:42 +000081 set_target_properties(scan-build PROPERTIES FOLDER "Misc")
Jonathan Roelofse9614322015-11-09 16:12:56 +000082endif()