1 set(LLVM_LINK_COMPONENTS support)
3 add_clang_library(clangFormat
4 AffectedRangeManager.cpp
6 ContinuationIndenter.cpp
7 DefinitionBlockSeparator.cpp
11 IntegerLiteralSeparatorFixer.cpp
12 MacroCallReconstructor.cpp
15 NamespaceEndCommentsFixer.cpp
16 ObjCPropertyAttributeOrderFixer.cpp
17 QualifierAlignmentFixer.cpp
18 SortJavaScriptImports.cpp
21 UnwrappedLineFormatter.cpp
22 UnwrappedLineParser.cpp
23 UsingDeclarationsSorter.cpp
30 clangToolingInclusions
33 file(GLOB_RECURSE files
36 ${CLANG_SOURCE_DIR}/include/clang/Format/*.h
37 ${CLANG_SOURCE_DIR}/tools/clang-format/*.cpp
38 ${CLANG_SOURCE_DIR}/unittests/Format/*.cpp
39 ${CLANG_SOURCE_DIR}/unittests/Format/*.h
42 set(check_format_depends)
44 foreach(file IN LISTS files)
45 add_custom_command(OUTPUT check_format_depend_${i}
46 COMMAND clang-format ${file} | diff -u ${file} -
48 COMMENT "Checking format of ${file}"
50 list(APPEND check_format_depends check_format_depend_${i})
53 add_custom_target(clang-format-check-format DEPENDS ${check_format_depends})
55 set(docs_tools_dir ${CLANG_SOURCE_DIR}/docs/tools)
57 set(format_style_depend ${CMAKE_CURRENT_BINARY_DIR}/format_style_depend)
58 set(dump_style dump_format_style.py)
59 set(style_options_rst ${CLANG_SOURCE_DIR}/docs/ClangFormatStyleOptions.rst)
60 add_custom_command(OUTPUT ${format_style_depend}
61 COMMAND ${Python3_EXECUTABLE} ${dump_style} && touch ${format_style_depend}
62 WORKING_DIRECTORY ${docs_tools_dir}
64 COMMENT "Updating ${style_options_rst}"
65 DEPENDS ${CLANG_SOURCE_DIR}/include/clang/Format/Format.h
66 ${CLANG_SOURCE_DIR}/include/clang/Tooling/Inclusions/IncludeStyle.h
68 ${docs_tools_dir}/plurals.txt
69 ${docs_tools_dir}/${dump_style}
71 add_custom_target(clang-format-style DEPENDS ${format_style_depend})
73 set(format_help_depend ${CMAKE_CURRENT_BINARY_DIR}/format_help_depend)
74 set(dump_help dump_format_help.py)
75 set(clang_format_rst ${CLANG_SOURCE_DIR}/docs/ClangFormat.rst)
76 add_custom_command(OUTPUT ${format_help_depend}
77 COMMAND ${Python3_EXECUTABLE} ${dump_help} -d ${CMAKE_BINARY_DIR}/bin &&
78 touch ${format_help_depend}
79 WORKING_DIRECTORY ${docs_tools_dir}
81 COMMENT "Updating ${clang_format_rst}"
84 ${docs_tools_dir}/${dump_help}
86 add_custom_target(clang-format-help DEPENDS ${format_help_depend})