-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.cmake
58 lines (51 loc) · 1.73 KB
/
Build.cmake
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
# Default compiler flags.
set(BUILD_SANITIZE_FLAGS "")
set(BUILD_WARNING_FLAGS "-Wall -Wextra -Wpedantic")
# Optional: Extensive compiler warnings for QA.
option(BUILD_EXTENSIVE_WARNINGS
"Add extensive compiler warnings to the build."
OFF
)
if (BUILD_EXTENSIVE_WARNINGS)
set(BUILD_WARNING_FLAGS
"${BUILD_WARNING_FLAGS} -Weverything \
-Wno-c++98-compat \
-Wno-c++98-compat-pedantic \
-Wno-c++98-c++11-compat"
)
endif (BUILD_EXTENSIVE_WARNINGS)
# Optional: Clang Tidy for QA, hard-coded to clang 7.0 for now.
option(BUILD_CLANG_TIDY
"Add static checks and lint to build using clang-tidy."
OFF
)
if (BUILD_CLANG_TIDY)
find_program(BUILD_CLANG_TIDY_PROGRAM NAMES clang-tidy80 clang-tidy)
if (BUILD_CLANG_TIDY_PROGRAM)
set(CMAKE_CXX_CLANG_TIDY ${BUILD_CLANG_TIDY_PROGRAM}
"-checks=bugprone*,\
clang-analyzer*,\
misc*,\
modernize*,\
performance*,\
portability*,\
readability*,\
-readability-else-after-return,\
-readability-implicit-bool-conversion"
)
endif (BUILD_CLANG_TIDY_PROGRAM)
endif (BUILD_CLANG_TIDY)
option(BUILD_INCLUDE_WHAT_YOU_USE
"Add include-what-you-use header include checks to the build."
OFF
)
if (BUILD_INCLUDE_WHAT_YOU_USE)
find_program(BUILD_IWYU_PROGRAM NAMES include-what-you-use)
if (BUILD_IWYU_PROGRAM)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${BUILD_IWYU_PROGRAM} "-Xiwyu" "--transitive_includes_only"
)
endif(BUILD_IWYU_PROGRAM)
endif (BUILD_INCLUDE_WHAT_YOU_USE)
# Combined compiler flags for convenience.
set(BUILD_COMPILER_FLAGS "${BUILD_WARNING_FLAGS} ${BUILD_SANITIZE_FLAGS}")