forked from oneapi-src/level-zero-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clang_tools.cmake
21 lines (21 loc) · 853 Bytes
/
clang_tools.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Copyright (C) 2019 Intel Corporation
# SPDX-License-Identifier: MIT
find_program(CLANG_FORMAT NAMES clang-format-7)
if(CLANG_FORMAT)
message(STATUS "Found clang-format-7: ${CLANG_FORMAT}")
add_custom_target(clang-format
COMMENT "Checking code formatting and fixing issues"
COMMAND
${CMAKE_SOURCE_DIR}/clang-format-patch.sh ${CMAKE_SOURCE_DIR} |
git -C ${CMAKE_SOURCE_DIR} apply -
)
add_custom_target(clang-format-check
COMMENT "Checking code formatting"
COMMAND
${CMAKE_SOURCE_DIR}/clang-format-patch.sh ${CMAKE_SOURCE_DIR}
| tee ${CMAKE_BINARY_DIR}/clang_format_results.patch
COMMAND ! [ -s ${CMAKE_BINARY_DIR}/clang_format_results.patch ]
)
else()
message(WARNING "clang-format-7 not found. clang-format and clang-format-check targets will be disabled.")
endif()