File: reformat.cmake

package info (click to toggle)
snapcast 0.34.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,252 kB
  • sloc: cpp: 40,067; python: 3,260; sh: 455; makefile: 16
file content (41 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
find_program(CLANG_FORMAT "clang-format")
if(CLANG_FORMAT)
  file(GLOB_RECURSE CHECK_CXX_SOURCE_FILES common/*.[ch]pp client/*.[ch]pp
       server/*.[ch]pp)

  list(REMOVE_ITEM CHECK_CXX_SOURCE_FILES "${CMAKE_SOURCE_DIR}/common/json.hpp")

  add_custom_target(
    reformat-c++
    COMMAND ${CLANG_FORMAT} -i -style=file ${CHECK_CXX_SOURCE_FILES}
    COMMENT "Auto formatting of all source files with ${CLANG_FORMAT}")
endif()

find_program(CMAKE_FORMAT "cmake-format")
if(CMAKE_FORMAT)
  file(GLOB_RECURSE CHECK_CMAKE_SOURCE_FILES CMakeLists.txt *.cmake)

  add_custom_target(
    reformat-cmake
    COMMAND ${CMAKE_FORMAT} -i ${CHECK_CMAKE_SOURCE_FILES}
    COMMENT "Auto formatting of all CMakeLists.txt files with ${CMAKE_FORMAT}")
endif()

find_program(AUTOPEP "autopep8")
if(AUTOPEP)
  file(GLOB_RECURSE CHECK_PYTHON_SOURCE_FILES *.py)

  add_custom_target(
    reformat-python
    COMMAND ${AUTOPEP} -i ${CHECK_PYTHON_SOURCE_FILES}
    COMMENT "Auto formatting of all Python files with ${AUTOPEP}")
endif()

if(CLANG_FORMAT
   AND CMAKE_FORMAT
   AND AUTOPEP)
  add_custom_target(
    reformat
    DEPENDS reformat-cmake reformat-c++ reformat-python
    COMMENT "Auto formatting of all source and CMakeLists.txt files")
endif()