https://github.com/DeepeshWR created 
https://github.com/llvm/llvm-project/pull/215761

clang-tools-extra tests depend on the llvm-bcanalyzer CMake target, which 
exists in LLVM's CMake project but is not visible when Clang is built 
separately from LLVM. This causes CMake errors when CLANG_INCLUDE_TESTS is ON 
but the LLVM tools are not available.

This patch introduces CLANG_TOOLS_EXTRA_INCLUDE_TESTS as a separate CMake 
option to control clang-tools-extra tests independently, allowing users to 
build Clang with tests enabled (CLANG_INCLUDE_TESTS=ON) while disabling 
clang-tools-extra tests (CLANG_TOOLS_EXTRA_INCLUDE_TESTS=OFF) when building 
Clang separately from LLVM.

Without this patch, the following error occurs when CLANG_INCLUDE_TESTS is ON:

```
  CMake Error at AddLLVM.cmake:2113 (add_dependencies):
    The dependency target "llvm-bcanalyzer" of target
    "check-clang-extra-clang-tidy-infrastructure-..." does not exist.
```

>From c839cdad223e952acc8ed02c24df47eecb665b17 Mon Sep 17 00:00:00 2001
From: Deepesh Varatharajan <[email protected]>
Date: Wed, 12 Aug 2026 02:06:30 -0700
Subject: [PATCH] [clang-tools-extra] Add separate
 CLANG_TOOLS_EXTRA_INCLUDE_TESTS option for tests

clang-tools-extra tests depend on the llvm-bcanalyzer CMake target, which
exists in LLVM's CMake project but is not visible when Clang is built
separately from LLVM. This causes CMake errors when CLANG_INCLUDE_TESTS
is ON but the LLVM tools are not available.

This patch introduces CLANG_TOOLS_EXTRA_INCLUDE_TESTS as a separate CMake
option to control clang-tools-extra tests independently, allowing users to
build Clang with tests enabled (CLANG_INCLUDE_TESTS=ON) while disabling
clang-tools-extra tests (CLANG_TOOLS_EXTRA_INCLUDE_TESTS=OFF) when building
Clang separately from LLVM.

Without this patch, the following error occurs when CLANG_INCLUDE_TESTS is ON:

  CMake Error at AddLLVM.cmake:2113 (add_dependencies):
    The dependency target "llvm-bcanalyzer" of target
    "check-clang-extra-clang-tidy-infrastructure-..." does not exist.
---
 clang-tools-extra/CMakeLists.txt                 | 4 ++--
 clang-tools-extra/clangd/CMakeLists.txt          | 2 +-
 clang-tools-extra/include-cleaner/CMakeLists.txt | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index 87050db4e0e75..3824129f8a6ce 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -8,7 +8,7 @@ option(CLANG_TIDY_ENABLE_STATIC_ANALYZER
 option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS
   "Enable query-based custom checks in clang-tidy" ON)
 
-if(CLANG_INCLUDE_TESTS)
+if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
   umbrella_lit_testsuite_begin(check-clang-tools)
 
   option(CLANG_TOOLS_TEST_USE_VG "Run Clang tools' tests under Valgrind" OFF)
@@ -45,7 +45,7 @@ if (CLANG_ENABLE_CLANGD)
 endif()
 
 # Add the common testsuite after all the tools.
-if(CLANG_INCLUDE_TESTS)
+if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
   add_subdirectory(test)
   add_subdirectory(unittests)
   umbrella_lit_testsuite_end(check-clang-tools)
diff --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 9fa7d92d8374c..6e1597a607ed9 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -218,7 +218,7 @@ endif()
 option(CLANGD_BUILD_DEXP "Build the dexp tool as part of Clangd" ON)
 llvm_canonicalize_cmake_booleans(CLANGD_BUILD_DEXP)
 
-if(CLANG_INCLUDE_TESTS)
+if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
   add_subdirectory(test)
   add_subdirectory(unittests)
 endif()
diff --git a/clang-tools-extra/include-cleaner/CMakeLists.txt 
b/clang-tools-extra/include-cleaner/CMakeLists.txt
index dc147f9ca08df..4855577dec98d 100644
--- a/clang-tools-extra/include-cleaner/CMakeLists.txt
+++ b/clang-tools-extra/include-cleaner/CMakeLists.txt
@@ -1,7 +1,7 @@
 include_directories(include)
 add_subdirectory(lib)
 add_subdirectory(tool)
-if(CLANG_INCLUDE_TESTS)
+if(CLANG_TOOLS_EXTRA_INCLUDE_TESTS)
   add_subdirectory(test)
   add_subdirectory(unittests)
 endif()

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to