[TargetVersion] Only enable on RISC-V and AArch64 (#115991)
[llvm-project.git] / clang / tools / scan-build-py / CMakeLists.txt
blob9273eb5ed977e452f7e6dd967ebfbacc8c154dc9
1 set (BinFiles
2      "analyze-build"
3      "intercept-build"
4      "scan-build")
6 set (LibExecs
7      "analyze-c++"
8      "analyze-cc"
9      "intercept-c++"
10      "intercept-cc")
12 set (LibScanbuild
13      "__init__.py"
14      "analyze.py"
15      "arguments.py"
16      "clang.py"
17      "compilation.py"
18      "intercept.py"
19      "report.py"
20      "shell.py")
22 set (LibScanbuildResources
23      "scanview.css"
24      "selectable.js"
25      "sorttable.js")
27 # libear is compiled dynamically in build_libear using the specified cc
28 # compiler.
29 set (LibEar
30      "__init__.py"
31      "config.h.in"
32      "ear.c")
34 foreach(BinFile ${BinFiles})
35   if ("${BinFile}" STREQUAL "scan-build")
36     # Need to rename scan-build to scan-build-py to prevent overwriting
37     # scan-build Perl implementation.
38     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/scan-build-py
39                        COMMAND ${CMAKE_COMMAND} -E make_directory
40                          ${CMAKE_BINARY_DIR}/bin
41                        COMMAND ${CMAKE_COMMAND} -E copy
42                          ${CMAKE_CURRENT_SOURCE_DIR}/bin/scan-build
43                          ${CMAKE_BINARY_DIR}/bin/scan-build-py
44                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/scan-build)
45     install (PROGRAMS "bin/scan-build"
46              DESTINATION "${CMAKE_INSTALL_BINDIR}"
47              RENAME scan-build-py
48              COMPONENT scan-build-py)
49     list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/scan-build-py)
50   else()
51     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${BinFile}
52                        COMMAND ${CMAKE_COMMAND} -E make_directory
53                          ${CMAKE_BINARY_DIR}/bin
54                        COMMAND ${CMAKE_COMMAND} -E copy
55                          ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}
56                          ${CMAKE_BINARY_DIR}/bin/
57                        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile})
58     install(PROGRAMS bin/${BinFile}
59             DESTINATION "${CMAKE_INSTALL_BINDIR}"
60             COMPONENT scan-build-py)
61     list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile})
62   endif()
63 endforeach()
65 foreach(lib ${LibExecs})
66   add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/libexec/${lib}
67                      COMMAND ${CMAKE_COMMAND} -E make_directory
68                        ${CMAKE_BINARY_DIR}/libexec
69                      COMMAND ${CMAKE_COMMAND} -E copy
70                        ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${lib}
71                        ${CMAKE_BINARY_DIR}/libexec/
72                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${lib})
73   list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${lib})
74   install(PROGRAMS libexec/${lib}
75           DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}"
76           COMPONENT scan-build-py)
77 endforeach()
79 foreach(lib ${LibScanbuild})
80   add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib}
81                      COMMAND ${CMAKE_COMMAND} -E make_directory
82                        ${CMAKE_BINARY_DIR}/lib
83                      COMMAND ${CMAKE_COMMAND} -E make_directory
84                        ${CMAKE_BINARY_DIR}/lib/libscanbuild
85                      COMMAND ${CMAKE_COMMAND} -E copy
86                        ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib}
87                        ${CMAKE_BINARY_DIR}/lib/libscanbuild/
88                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib})
89   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib})
90   install(FILES lib/libscanbuild/${lib}
91           DESTINATION lib/libscanbuild
92           COMPONENT scan-build-py)
93 endforeach()
95 foreach(resource ${LibScanbuildResources})
96   add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource}
97                      COMMAND ${CMAKE_COMMAND} -E make_directory
98                        ${CMAKE_BINARY_DIR}/lib
99                      COMMAND ${CMAKE_COMMAND} -E make_directory
100                        ${CMAKE_BINARY_DIR}/lib/libscanbuild
101                      COMMAND ${CMAKE_COMMAND} -E make_directory
102                        ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources
103                      COMMAND ${CMAKE_COMMAND} -E copy
104                        ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource}
105                        ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources
106                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource})
107   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource})
108   install(FILES lib/libscanbuild/resources/${resource}
109           DESTINATION lib/libscanbuild/resources
110           COMPONENT scan-build-py)
111 endforeach()
113 foreach(lib ${LibEar})
114   add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/lib/libear/${lib}
115                      COMMAND ${CMAKE_COMMAND} -E make_directory
116                        ${CMAKE_BINARY_DIR}/lib
117                      COMMAND ${CMAKE_COMMAND} -E make_directory
118                        ${CMAKE_BINARY_DIR}/lib/libear
119                      COMMAND ${CMAKE_COMMAND} -E copy
120                        ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib}
121                        ${CMAKE_BINARY_DIR}/lib/libear/
122                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib})
123   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib})
124   install(FILES lib/libear/${lib}
125           DESTINATION lib/libear
126           COMPONENT scan-build-py)
127 endforeach()
129 add_custom_target(scan-build-py ALL DEPENDS ${Depends})
130 add_llvm_install_targets("install-scan-build-py"
131                          DEPENDS scan-build-py
132                          COMPONENT scan-build-py)