[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / CMakeLists.txt
blob299a35723b59d5f43dbac7116bfc17ee1dd95f85
1 # Test runner infrastructure for Clang. This configures the Clang test trees
2 # for use by Lit, and delegates to LLVM's lit test handlers.
4 llvm_canonicalize_cmake_booleans(
5   CLANG_BUILD_EXAMPLES
6   CLANG_BUILT_STANDALONE
7   CLANG_DEFAULT_PIE_ON_LINUX
8   CLANG_ENABLE_ARCMT
9   CLANG_ENABLE_STATIC_ANALYZER
10   CLANG_PLUGIN_SUPPORT
11   CLANG_SPAWN_CC1
12   CLANG_ENABLE_CIR
13   ENABLE_BACKTRACES
14   LLVM_BUILD_EXAMPLES
15   LLVM_BYE_LINK_INTO_TOOLS
16   LLVM_ENABLE_PLUGINS
17   LLVM_ENABLE_ZLIB
18   LLVM_ENABLE_ZSTD
19   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
20   LLVM_ENABLE_THREADS
21   LLVM_ENABLE_REVERSE_ITERATION
22   LLVM_WITH_Z3
23   PPC_LINUX_DEFAULT_IEEELONGDOUBLE
24   LLVM_TOOL_LLVM_DRIVER_BUILD
25   )
27 configure_lit_site_cfg(
28   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
29   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
30   MAIN_CONFIG
31   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
32   PATHS
33   "LLVM_SOURCE_DIR"
34   "LLVM_BINARY_DIR"
35   "LLVM_TOOLS_DIR"
36   "LLVM_LIBS_DIR"
37   "SHLIBDIR"
38   "LLVM_LIT_TOOLS_DIR"
39   "LLVM_EXTERNAL_LIT"
40   "CLANG_BINARY_DIR"
41   "CLANG_SOURCE_DIR"
42   "CURRENT_TOOLS_DIR"
43   "CMAKE_LIBRARY_OUTPUT_DIRECTORY"
44   )
46 configure_lit_site_cfg(
47   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
48   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
49   MAIN_CONFIG
50   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
51   PATHS
52   "LLVM_SOURCE_DIR"
53   "LLVM_BINARY_DIR"
54   "LLVM_TOOLS_DIR"
55   "LLVM_LIBS_DIR"
56   "CLANG_BINARY_DIR"
57   "SHLIBDIR"
58   )
60 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
61 if(CLANG_TEST_USE_VG)
62   set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
63 endif ()
65 list(APPEND CLANG_TEST_DEPS
66   apinotes-test
67   c-index-test
68   clang
69   clang-fuzzer-dictionary
70   clang-resource-headers
71   clang-format
72   clang-tblgen
73   clang-offload-bundler
74   clang-import-test
75   clang-rename
76   clang-refactor
77   clang-diff
78   clang-installapi
79   clang-scan-deps
80   clang-linker-wrapper
81   clang-nvlink-wrapper
82   clang-offload-bundler
83   clang-offload-packager
84   diagtool
85   hmaptool
86   )
87   
88 if(CLANG_ENABLE_STATIC_ANALYZER)
89   list(APPEND CLANG_TEST_DEPS
90     clang-check
91     clang-extdef-mapping
92     )
93 endif()
95 if (CLANG_ENABLE_ARCMT)
96   list(APPEND CLANG_TEST_DEPS
97     arcmt-test
98     c-arcmt-test
99   )
100 endif ()
102 if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
103   list(APPEND CLANG_TEST_DEPS
104     Attribute
105     AnnotateFunctions
106     CallSuperAttr
107     PluginsOrder
108     PrintFunctionNames
109     LLVMPrintFunctionNames
110     )
111 endif ()
113 set(CLANG_TEST_PARAMS
114   USE_Z3_SOLVER=0
115   )
117 if( NOT CLANG_BUILT_STANDALONE )
118   list(APPEND CLANG_TEST_DEPS
119     llvm-config
120     FileCheck count not
121     llc
122     llvm-ar
123     llvm-as
124     llvm-bcanalyzer
125     llvm-cat
126     llvm-cxxfilt
127     llvm-dis
128     llvm-dwarfdump
129     llvm-ifs
130     llvm-lto2
131     llvm-modextract
132     llvm-nm
133     llvm-objcopy
134     llvm-objdump
135     llvm-pdbutil
136     llvm-profdata
137     llvm-rc
138     llvm-readelf
139     llvm-readobj
140     llvm-readtapi
141     llvm-strip
142     llvm-symbolizer
143     llvm-windres
144     obj2yaml
145     opt
146     split-file
147     yaml2obj
148     )
150   if(TARGET llvm-lto)
151     list(APPEND CLANG_TEST_DEPS llvm-lto)
152   endif()
153 endif()
155 if(CLANG_ENABLE_STATIC_ANALYZER)
156   if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
157     list(APPEND CLANG_TEST_DEPS
158       SampleAnalyzerPlugin
159       CheckerDependencyHandlingAnalyzerPlugin
160       CheckerOptionHandlingAnalyzerPlugin
161       )
162   endif()
163 endif()
165 if (HAVE_CLANG_REPL_SUPPORT)
166   list(APPEND CLANG_TEST_DEPS
167     clang-repl
168     )
169 endif()
171 # Copy gen_ast_dump_json_test.py to the clang build dir. This allows invoking
172 # it without having to pass the --clang= argument
173 configure_file(AST/gen_ast_dump_json_test.py
174   ${CLANG_BINARY_DIR}/bin/gen_ast_dump_json_test.py COPYONLY)
176 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
177 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang/Tests")
179 add_lit_testsuite(check-clang "Running the Clang regression tests"
180   ${CMAKE_CURRENT_BINARY_DIR}
181   #LIT ${LLVM_LIT}
182   PARAMS ${CLANG_TEST_PARAMS}
183   DEPENDS ${CLANG_TEST_DEPS}
184   ARGS ${CLANG_TEST_EXTRA_ARGS}
185   )
187 add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
188   PARAMS ${CLANG_TEST_PARAMS}
189   DEPENDS ${CLANG_TEST_DEPS}
190   FOLDER "Clang tests/Suites"
193 # Add a legacy target spelling: clang-test
194 add_custom_target(clang-test)
195 add_dependencies(clang-test check-clang)
196 set_target_properties(clang-test PROPERTIES FOLDER "Clang/Tests")
198 # FIXME: This logic can be removed once all buildbots have moved
199 # debuginfo-test from clang/test to llvm/projects or monorepo.
200 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests)
201   message(WARNING "Including debuginfo-tests in clang/test is deprecated.  Move to llvm/projects or use monorepo.")
202   if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt)
203     add_subdirectory(debuginfo-tests)
204   endif()
205 endif()