Skip to content

Commit

Permalink
[clang-format][NFC] Add CMake target clang-format-check-format (#95873)
Browse files Browse the repository at this point in the history
Adapted from polly-check-format.
  • Loading branch information
owenca authored Jun 21, 2024
1 parent a083e50 commit f2b17d2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions clang/lib/Format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,27 @@ add_clang_library(clangFormat
clangToolingCore
clangToolingInclusions
)

file(GLOB_RECURSE files
*.cpp
*.h
../../include/clang/Format/*.h
../../tools/clang-format/*.cpp
../../unittests/Format/*.cpp
../../unittests/Format/*.h
)

set(check_format_depends)
set(i 0)
foreach (file IN LISTS files)
add_custom_command(OUTPUT clang-format-check-format${i}
COMMAND clang-format ${file} | diff -u ${file} -
VERBATIM
COMMENT "Checking format of ${file}..."
)
list(APPEND check_format_depends "clang-format-check-format${i}")

math(EXPR i ${i}+1)
endforeach ()

add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})

0 comments on commit f2b17d2

Please sign in to comment.