2 # The find_package changes these variables. This leaves the build in an odd
3 # state. Calling cmake a second time tries to write site config information in
4 # the system's libc++. Restoring these setting after testing fixes this issue.
5 set(LLVM_DIR_SAVE ${LLVM_DIR})
6 set(Clang_DIR_SAVE ${Clang_DIR})
10 find_package(Clang 18)
14 abi_tag_on_virtual.cpp
15 header_exportable_declarations.cpp
17 proper_version_checks.cpp
19 robust_against_adl.cpp
26 message(STATUS "Could not find a suitable version of the Clang development package;
27 custom libc++ clang-tidy checks will not be available.")
31 set(LLVM_DIR "${LLVM_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for LLVM." FORCE)
32 set(Clang_DIR "${Clang_DIR_SAVE}" CACHE PATH "The directory containing a CMake configuration file for Clang." FORCE)
34 message(STATUS "Found system-installed LLVM ${LLVM_PACKAGE_VERSION} with headers in ${LLVM_INCLUDE_DIRS}")
36 set(CMAKE_CXX_STANDARD 20)
38 # Link only against clangTidy itself, not anything that clangTidy uses; otherwise we run setup code multiple times
39 # which results in clang-tidy crashing
40 set_target_properties(clangTidy PROPERTIES INTERFACE_LINK_LIBRARIES "")
41 # ClangTargets.cmake doesn't set the include paths, so we have to do it
42 target_include_directories(clangTidy INTERFACE
46 target_compile_options(clangTidy INTERFACE
48 -fno-sanitize=address,hwaddress,undefined,thread,leak # ignore any sanitizers
51 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
52 target_compile_options(clangTidy INTERFACE
53 -fno-sanitize=memory,dataflow
57 add_library(cxx-tidy MODULE ${SOURCES})
58 target_link_libraries(cxx-tidy clangTidy)
60 set_target_properties(cxx-tidy PROPERTIES
62 CXX_STANDARD_REQUIRED YES
65 set_target_properties(cxx-tidy PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
66 set(CMAKE_SHARED_MODULE_SUFFIX_CXX .plugin) # Use a portable suffix to simplify how we can find it from Lit