Author: Deepesh Varatharajan
Date: 2026-08-29T16:04:52-04:00
New Revision: f5fd1587149a039f4592b6e15647668175bb17a7

URL: 
https://github.com/llvm/llvm-project/commit/f5fd1587149a039f4592b6e15647668175bb17a7
DIFF: 
https://github.com/llvm/llvm-project/commit/f5fd1587149a039f4592b6e15647668175bb17a7.diff

LOG: [clang-tools-extra] Add separate CLANG_TOOLS_EXTRA_INCLUDE_TESTS option 
(#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.

For backwards compatibility, CLANG_INCLUDE_TESTS=OFF continues
to turn off clang-tools-extra tests as well.

Added: 
    

Modified: 
    clang-tools-extra/CMakeLists.txt
    clang-tools-extra/clangd/CMakeLists.txt
    clang-tools-extra/include-cleaner/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/CMakeLists.txt 
b/clang-tools-extra/CMakeLists.txt
index 0dbdeaed9a9a2..291e130ca3901 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)
@@ -46,7 +48,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 151f4ee028b87..3aa1b7bddb994 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -219,7 +219,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

Reply via email to