-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
69 lines (61 loc) · 1.61 KB
/
CMakeLists.txt
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.24)
project(example)
add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME}
PRIVATE
src/main.cpp
)
if(CMAKE_EXPORT_COMPILE_COMMANDS)
include(ProcessorCount)
ProcessorCount(N)
set(IWYU_TOOL_EXE "iwyu_tool.py" CACHE STRING "Optional path to a different executable")
set(FIX_INCLUDES_EXE "fix_includes.py" CACHE STRING "Optional path to a different executable")
set(RUN_CLANG_TIDY_EXE "run-clang-tidy" CACHE STRING "Optional path to a different executable")
add_custom_target(iwyu
COMMAND
${IWYU_TOOL_EXE}
-p ${CMAKE_BINARY_DIR}
--jobs ${N}
-- -Xiwyu
--error
-Xiwyu
--mapping_file=${CMAKE_SOURCE_DIR}/.lint/iwyu.imp
)
add_custom_target(fix-includes
COMMAND
${IWYU_TOOL_EXE}
-p ${CMAKE_BINARY_DIR}
--jobs ${N}
-- -Xiwyu
--error
-Xiwyu
--mapping_file=${CMAKE_SOURCE_DIR}/.lint/iwyu.imp
| ${FIX_INCLUDES_EXE}
--noreorder
--nosafe_headers
)
add_custom_target(clang-tidy
COMMAND
${RUN_CLANG_TIDY_EXE}
-p ${CMAKE_BINARY_DIR}
-j ${N}
)
add_custom_target(check-format
COMMAND
find
${CMAKE_SOURCE_DIR}/src
-iname '*.h' -o
-iname '*.hpp' -o
-iname '*.cpp'
| xargs clang-format -n --Werror
)
add_custom_target(clang-format
COMMAND
find
${CMAKE_SOURCE_DIR}/src
-iname '*.h' -o
-iname '*.hpp' -o
-iname '*.cpp'
| xargs clang-format -i
)
endif()