Skip to content

Commit 664f345

Browse files
committed
[libc++] Improves clang-tidy configuration.
The current clang-tidy settings work in the CI but not on all systems outside the CI. - The range 16...17 doesn't work when only clang-17 is installed. - Running CMake a second time will fail. This addresses these issues. Reviewed By: philnik, #libc Differential Revision: https://reviews.llvm.org/D144785
1 parent cb2d04d commit 664f345

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

libcxx/test/tools/clang_tidy_checks/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
44
set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
55

6-
find_package(Clang 16...17)
6+
# The find_package changes these variables. This leaves the build in an odd
7+
# state. Calling cmake a second time tries to write site config information in
8+
# the system's libc++. Restoring these setting after testing fixes this issue.
9+
set(LLVM_DIR_SAVE ${LLVM_DIR})
10+
set(Clang_DIR_SAVE ${Clang_DIR})
11+
12+
find_package(Clang 16)
13+
if (NOT Clang_FOUND)
14+
find_package(Clang 17)
15+
endif()
716

817
set(SOURCES
918
abi_tag_on_virtual.cpp
@@ -21,6 +30,9 @@ if(NOT Clang_FOUND)
2130
return()
2231
endif()
2332

33+
set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
34+
set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
35+
2436
message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
2537

2638
set(CMAKE_CXX_STANDARD 20)

0 commit comments

Comments
 (0)