Skip to content

Commit f2b17d2

Browse files
authored
[clang-format][NFC] Add CMake target clang-format-check-format (#95873)
Adapted from polly-check-format.
1 parent a083e50 commit f2b17d2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

clang/lib/Format/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,27 @@ add_clang_library(clangFormat
2929
clangToolingCore
3030
clangToolingInclusions
3131
)
32+
33+
file(GLOB_RECURSE files
34+
*.cpp
35+
*.h
36+
../../include/clang/Format/*.h
37+
../../tools/clang-format/*.cpp
38+
../../unittests/Format/*.cpp
39+
../../unittests/Format/*.h
40+
)
41+
42+
set(check_format_depends)
43+
set(i 0)
44+
foreach (file IN LISTS files)
45+
add_custom_command(OUTPUT clang-format-check-format${i}
46+
COMMAND clang-format ${file} | diff -u ${file} -
47+
VERBATIM
48+
COMMENT "Checking format of ${file}..."
49+
)
50+
list(APPEND check_format_depends "clang-format-check-format${i}")
51+
52+
math(EXPR i ${i}+1)
53+
endforeach ()
54+
55+
add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})

0 commit comments

Comments
 (0)