[Flang] remove whole-archive option for AIX linker (#76039)
[llvm-project.git] / clang / test / CMakeLists.txt
blobf17ded42a019c2547cc92a4446ad0b62fdac6f3e
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   ENABLE_BACKTRACES
13   LLVM_ENABLE_ZLIB
14   LLVM_ENABLE_ZSTD
15   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
16   LLVM_ENABLE_THREADS
17   LLVM_ENABLE_REVERSE_ITERATION
18   LLVM_WITH_Z3
19   PPC_LINUX_DEFAULT_IEEELONGDOUBLE
20   LLVM_TOOL_LLVM_DRIVER_BUILD
21   )
23 configure_lit_site_cfg(
24   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
25   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
26   MAIN_CONFIG
27   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
28   PATHS
29   "LLVM_SOURCE_DIR"
30   "LLVM_BINARY_DIR"
31   "LLVM_TOOLS_DIR"
32   "LLVM_LIBS_DIR"
33   "SHLIBDIR"
34   "LLVM_LIT_TOOLS_DIR"
35   "LLVM_EXTERNAL_LIT"
36   "CLANG_BINARY_DIR"
37   "CLANG_SOURCE_DIR"
38   "CURRENT_TOOLS_DIR"
39   "CMAKE_LIBRARY_OUTPUT_DIRECTORY"
40   )
42 configure_lit_site_cfg(
43   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
44   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
45   MAIN_CONFIG
46   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
47   PATHS
48   "LLVM_SOURCE_DIR"
49   "LLVM_BINARY_DIR"
50   "LLVM_TOOLS_DIR"
51   "LLVM_LIBS_DIR"
52   "CLANG_BINARY_DIR"
53   "SHLIBDIR"
54   )
56 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
57 if(CLANG_TEST_USE_VG)
58   set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
59 endif ()
61 list(APPEND CLANG_TEST_DEPS
62   apinotes-test
63   c-index-test
64   clang
65   clang-fuzzer-dictionary
66   clang-resource-headers
67   clang-format
68   clang-tblgen
69   clang-offload-bundler
70   clang-import-test
71   clang-rename
72   clang-refactor
73   clang-diff
74   clang-scan-deps
75   clang-linker-wrapper
76   clang-offload-bundler
77   clang-offload-packager
78   diagtool
79   hmaptool
80   )
81   
82 if(CLANG_ENABLE_STATIC_ANALYZER)
83   list(APPEND CLANG_TEST_DEPS
84     clang-check
85     clang-extdef-mapping
86     )
87 endif()
89 if (CLANG_ENABLE_ARCMT)
90   list(APPEND CLANG_TEST_DEPS
91     arcmt-test
92     c-arcmt-test
93   )
94 endif ()
96 if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
97   list(APPEND CLANG_TEST_DEPS
98     Attribute
99     AnnotateFunctions
100     CallSuperAttr
101     PluginsOrder
102     PrintFunctionNames
103     LLVMPrintFunctionNames
104     )
105 endif ()
107 set(CLANG_TEST_PARAMS
108   USE_Z3_SOLVER=0
109   )
111 if( NOT CLANG_BUILT_STANDALONE )
112   list(APPEND CLANG_TEST_DEPS
113     llvm-config
114     FileCheck count not
115     llc
116     llvm-ar
117     llvm-as
118     llvm-bcanalyzer
119     llvm-cat
120     llvm-cxxfilt
121     llvm-dis
122     llvm-dwarfdump
123     llvm-ifs
124     llvm-lto2
125     llvm-modextract
126     llvm-nm
127     llvm-objcopy
128     llvm-objdump
129     llvm-pdbutil
130     llvm-profdata
131     llvm-rc
132     llvm-readelf
133     llvm-readobj
134     llvm-strip
135     llvm-symbolizer
136     llvm-windres
137     opt
138     split-file
139     yaml2obj
140     )
142   if(TARGET llvm-lto)
143     list(APPEND CLANG_TEST_DEPS llvm-lto)
144   endif()
145 endif()
147 if(CLANG_ENABLE_STATIC_ANALYZER)
148   if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
149     list(APPEND CLANG_TEST_DEPS
150       SampleAnalyzerPlugin
151       CheckerDependencyHandlingAnalyzerPlugin
152       CheckerOptionHandlingAnalyzerPlugin
153       )
154   endif()
155 endif()
157 if (HAVE_CLANG_REPL_SUPPORT)
158   list(APPEND CLANG_TEST_DEPS
159     clang-repl
160     )
161 endif()
163 # Copy gen_ast_dump_json_test.py to the clang build dir. This allows invoking
164 # it without having to pass the --clang= argument
165 configure_file(AST/gen_ast_dump_json_test.py
166   ${CLANG_BINARY_DIR}/bin/gen_ast_dump_json_test.py COPYONLY)
168 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
169 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
171 add_lit_testsuite(check-clang "Running the Clang regression tests"
172   ${CMAKE_CURRENT_BINARY_DIR}
173   #LIT ${LLVM_LIT}
174   PARAMS ${CLANG_TEST_PARAMS}
175   DEPENDS ${CLANG_TEST_DEPS}
176   ARGS ${CLANG_TEST_EXTRA_ARGS}
177   )
178 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
180 add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
181   PARAMS ${CLANG_TEST_PARAMS}
182   DEPENDS ${CLANG_TEST_DEPS}
183   FOLDER "Clang tests/Suites"
186 # Add a legacy target spelling: clang-test
187 add_custom_target(clang-test)
188 add_dependencies(clang-test check-clang)
189 set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")
191 # FIXME: This logic can be removed once all buildbots have moved
192 # debuginfo-test from clang/test to llvm/projects or monorepo.
193 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests)
194   message(WARNING "Including debuginfo-tests in clang/test is deprecated.  Move to llvm/projects or use monorepo.")
195   if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt)
196     add_subdirectory(debuginfo-tests)
197   endif()
198 endif()