File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
cmake_minimum_required (VERSION 3.8)
2
2
3
+ ###############################################################################
4
+ # App tests
5
+ ###############################################################################
6
+
3
7
# Set directories for test output files, input data and binaries.
4
8
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /output )
5
9
add_definitions (-DOUTPUTDIR=\"${CMAKE_CURRENT_BINARY_DIR} /output /\")
@@ -83,3 +87,26 @@ else ()
83
87
endif ()
84
88
85
89
message (STATUS "${FontBold} You can run `make cli-test` to build the tests and `make test` to run them.${FontReset} " )
90
+
91
+ ###############################################################################
92
+ # Clang format
93
+ ###############################################################################
94
+
95
+ find_program (CLANG_FORMAT "clang-format-14" )
96
+
97
+ if (CLANG_FORMAT STREQUAL "CLANG_FORMAT-NOTFOUND" )
98
+ find_program (CLANG_FORMAT "clang-format" )
99
+ endif ()
100
+
101
+ if (NOT CLANG_FORMAT STREQUAL "CLANG_FORMAT-NOTFOUND" )
102
+ add_custom_target (check_format ALL "find" "${CMAKE_CURRENT_SOURCE_DIR} /../src" "-name" "'*.[ch]pp'" "-exec"
103
+ ${CLANG_FORMAT} "-style=file" "-n" "-Werror" "{}" "+"
104
+ COMMENT "Checking the source-code with clang-format." )
105
+
106
+
107
+ add_custom_target (reformat "find" "${CMAKE_CURRENT_SOURCE_DIR} /../src" "-name" "'*.[ch]pp'" "-exec"
108
+ ${CLANG_FORMAT} "-style=file" "-i" "{}" "+"
109
+ COMMENT "Reformatting the source-code with clang-format." )
110
+ else ()
111
+ message (STATUS "clang_format not found; not adding the 'check_format' and 'reformat' targets." )
112
+ endif ()
You can’t perform that action at this time.
0 commit comments