[libcxx-commits] [PATCH] D144785: [libc++] Improves clang-tidy configuration.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Feb 25 06:35:59 PST 2023


Mordante created this revision.
Mordante added a reviewer: philnik.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144785

Files:
  libcxx/test/tools/clang_tidy_checks/CMakeLists.txt


Index: libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
===================================================================
--- libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+++ libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
@@ -3,7 +3,16 @@
 set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
 set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
 
-find_package(Clang 16...17)
+# The find_package changes these variables. This leaves the build in an odd
+# state. Calling cmake a second time tries to write site config information in
+# the system's libc++. Restoring these setting after testing fixes this issue.
+set(LLVM_DIR_SAVE ${LLVM_DIR})
+set(Clang_DIR_SAVE ${Clang_DIR})
+
+find_package(Clang 16)
+if (NOT Clang_FOUND)
+  find_package(Clang 17)
+endif()
 
 set(SOURCES
     abi_tag_on_virtual.cpp
@@ -21,6 +30,9 @@
   return()
 endif()
 
+set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
+set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
+
 message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
 
 set(CMAKE_CXX_STANDARD 20)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144785.500427.patch
Type: text/x-patch
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230225/70af5f19/attachment.bin>


More information about the libcxx-commits mailing list