https://github.com/DeepeshWR updated https://github.com/llvm/llvm-project/pull/215761
>From a5c2300dede941771cedc51988514fefc3641ff7 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 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 an additional CMake option to control clang-tools-extra tests independently of other Clang tests. Users can 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. Guard the clang-tools-extra, clangd, and include-cleaner test targets with both CLANG_INCLUDE_TESTS and CLANG_TOOLS_EXTRA_INCLUDE_TESTS. The new option defaults to ON for backwards compatibility. Without this patch, the following error occurs when building Clang separately with CLANG_INCLUDE_TESTS=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 | 6 ++++-- clang-tools-extra/clangd/CMakeLists.txt | 2 +- clang-tools-extra/include-cleaner/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt index 87050db4e0e75..89e89195277b0 100644 --- a/clang-tools-extra/CMakeLists.txt +++ b/clang-tools-extra/CMakeLists.txt @@ -7,8 +7,10 @@ option(CLANG_TIDY_ENABLE_STATIC_ANALYZER "Include static analyzer checks in clang-tidy" ON) option(CLANG_TIDY_ENABLE_QUERY_BASED_CUSTOM_CHECKS "Enable query-based custom checks in clang-tidy" ON) +option(CLANG_TOOLS_EXTRA_INCLUDE_TESTS + "Generate build targets for Clang Extra Tools tests." ON) -if(CLANG_INCLUDE_TESTS) +if(CLANG_INCLUDE_TESTS AND 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 +47,7 @@ if (CLANG_ENABLE_CLANGD) endif() # Add the common testsuite after all the tools. -if(CLANG_INCLUDE_TESTS) +if(CLANG_INCLUDE_TESTS AND 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..bc70dbdf0853e 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_INCLUDE_TESTS AND 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..4ccd3da21f70a 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_INCLUDE_TESTS AND 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
