-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup_iwyu.cmake
67 lines (65 loc) · 2.27 KB
/
setup_iwyu.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
59
60
61
62
63
64
65
66
67
include_guard( DIRECTORY )
# include-what-you-use mappings file
# Mappings file format:
# { include: [ '@"mutt/.*"', private, '"mutt/mutt.h"', public ] },
# { include: [ '@"conn/.*"', private, '"conn/conn.h"', public ] },
set(IWYU_IMP "${CMAKE_CURRENT_SOURCE_DIR}/cmake/iwyu/iwyu.imp")
if(NOT EXISTS ${IWYU_IMP})
message(FATAL_ERROR "Unable to find file: ${IWYU_IMP}")
endif(NOT EXISTS ${IWYU_IMP})
# USAGE:
# cmake -E time cmake --build . --target TARGET_NAME_iwyu
iwyu_enabler(
PATHS
#${CONAN_BIN_DIRS}
${CONAN_BIN_DIRS_LLVM_TOOLS}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
IS_ENABLED
${ENABLE_IWYU}
CHECK_TARGETS
${LIB_NAME}
EXTRA_OPTIONS
-std=c++17
-DCLING_IS_ON=1
# include
-I${entt_includes}
# include
-I${basis_HEADER_DIR}
# include
-I${corrade_includes}
# Use the proper include directory,
# for clang-* it would be /usr/lib/llvm-*/lib/clang/*/include/.
# locate stddef.h | sed -ne '/^\/usr/p'
# see https://github.com/include-what-you-use/include-what-you-use/issues/679
-isystem/usr/lib/llvm-6.0/lib/clang/6.0.1/include
# -Xiwyu --transitive_includes_only
# pch_in_code: The file has an important header first
# -Xiwyu --pch_in_code
# no_comments: Do not add notes to the output
-Xiwyu --no_comments
# mapping_file: lookup file
-Xiwyu --mapping_file=${IWYU_IMP}
-Xiwyu --max_line_length=120
# see https://github.com/include-what-you-use/include-what-you-use/issues/760
-Wno-unknown-warning-option
-Wno-error
# disable all warnings
-Wno-everything
# when sorting includes, place quoted ones first.
-Xiwyu --quoted_includes_first
# suggests the more concise syntax introduced in C++17
-Xiwyu --cxx17ns
# max_line_length: maximum line length for includes.
# Note that this only affects comments and alignment thereof,
# the maximum line length can still be exceeded
# with long file names (default: 80).
-Xiwyu --max_line_length=180
#-Xiwyu --check_also=${CMAKE_CURRENT_SOURCE_DIR}/src/*
#-Xiwyu --check_also=${CMAKE_CURRENT_SOURCE_DIR}/src/*/*
#-Xiwyu --check_also=${CMAKE_CURRENT_SOURCE_DIR}/src/*/*/*
#-Xiwyu --check_also=${CMAKE_CURRENT_SOURCE_DIR}/src/*/*/*/*
#VERBOSE
REQUIRED
CHECK_TARGETS_DEPEND
)