xref: /llvm-project/clang-tools-extra/test/CMakeLists.txt (revision c0fdedfedf16317253619aa65b7c60102aa36fee)
1# Test runner infrastructure for Clang-based tools. This configures the Clang
2# test trees for use by Lit, and delegates to LLVM's lit test handlers.
3#
4# Note that currently we don't support stand-alone builds of Clang, you must
5# be building Clang from within a combined LLVM+Clang checkout..
6
7set(CLANG_TOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
8set(CLANG_TOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
9
10llvm_canonicalize_cmake_booleans(
11  CLANG_TIDY_ENABLE_STATIC_ANALYZER
12  CLANG_PLUGIN_SUPPORT
13  LLVM_INSTALL_TOOLCHAIN_ONLY
14  )
15
16configure_lit_site_cfg(
17  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
18  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
19  MAIN_CONFIG
20  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
21  )
22
23configure_lit_site_cfg(
24  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
25  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
26  MAIN_CONFIG
27  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
28  )
29
30set(CLANG_TOOLS_TEST_DEPS
31  # For the clang-doc tests that emit bitcode files.
32  llvm-bcanalyzer
33
34  # Individual tools we test.
35  clang-apply-replacements
36  clang-change-namespace
37  clang-doc
38  clang-include-fixer
39  clang-move
40  clang-query
41  clang-reorder-fields
42  find-all-symbols
43  modularize
44  pp-trace
45
46  # Unit tests
47  ExtraToolsUnitTests
48
49  # clang-tidy tests require it.
50  clang-resource-headers
51
52  clang-tidy
53)
54
55# Add lit test dependencies.
56set(LLVM_UTILS_DEPS
57  FileCheck count not
58)
59foreach(dep ${LLVM_UTILS_DEPS})
60  if(TARGET ${dep})
61    list(APPEND CLANG_TOOLS_TEST_DEPS ${dep})
62  endif()
63endforeach()
64
65if (NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB)
66  llvm_add_library(
67      CTTestTidyModule
68      MODULE clang-tidy/CTTestTidyModule.cpp
69      PLUGIN_TOOL clang-tidy)
70endif()
71
72if(TARGET CTTestTidyModule)
73    list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule)
74    target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
75    if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
76      set(LLVM_LINK_COMPONENTS
77        Support
78      )
79    endif()
80endif()
81
82add_lit_testsuite(check-clang-extra "Running clang-tools-extra/test"
83   ${CMAKE_CURRENT_BINARY_DIR}
84   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
85   )
86
87add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
88  DEPENDS ${CLANG_TOOLS_TEST_DEPS}
89  )
90