[flang][runtime] Make defined formatted I/O process format elementally (#74150)
[llvm-project.git] / libcxx / test / tools / clang_tidy_checks / CMakeLists.txt
blob260e90f45f577cbb768762d9c5002f56d664ec57
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})
8 find_package(Clang 17)
9 if (NOT Clang_FOUND)
10   find_package(Clang 18)
11 endif()
13 set(SOURCES
14     abi_tag_on_virtual.cpp
15     header_exportable_declarations.cpp
16     hide_from_abi.cpp
17     proper_version_checks.cpp
18     qualify_declval.cpp
19     robust_against_adl.cpp
20     uglify_attributes.cpp
22     libcpp_module.cpp
23    )
25 if(NOT Clang_FOUND)
26   message(STATUS "Could not find a suitable version of the Clang development package;
27                   custom libc++ clang-tidy checks will not be available.")
28   return()
29 endif()
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
43                            ${CLANG_INCLUDE_DIRS}
44                            ${LLVM_INCLUDE_DIRS}
45                           )
46 target_compile_options(clangTidy INTERFACE
47                        -fno-rtti
48                        -fno-sanitize=address,hwaddress,undefined,thread,leak # ignore any sanitizers
49                       )
51 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
52   target_compile_options(clangTidy INTERFACE
53                          -fno-sanitize=memory,dataflow
54                         )
55 endif()
57 add_library(cxx-tidy MODULE ${SOURCES})
58 target_link_libraries(cxx-tidy clangTidy)
60 set_target_properties(cxx-tidy PROPERTIES
61                       CXX_STANDARD 20
62                       CXX_STANDARD_REQUIRED YES
63                       CXX_EXTENSIONS NO)
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