File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ function(four_c_auto_define_module)
3838 # them on other users of the library.
3939 target_link_libraries (${_target} _objs PRIVATE four_c_private_compile_interface)
4040
41+ if (FOUR_C_ENABLE_IWYU)
42+ set_target_properties (
43+ ${_target} _objs PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ${FOUR_C_IWYU_EXECUTABLE}
44+ )
45+ endif ()
46+
4147 if (FOUR_C_ENABLE_DEVELOPER_MODE AND _parsed_NO_CYCLES)
4248 # Define an additional library built from the sources. In developer mode, we link unit tests against this library which can
4349 # be faster to build than lib4C.
Original file line number Diff line number Diff line change @@ -152,6 +152,17 @@ else()
152152 enable_compiler_flag_if_supported("-fno-trapping-math" )
153153endif ()
154154
155+ four_c_process_global_option(FOUR_C_ENABLE_IWYU "Enable include-what-you-use" OFF )
156+ if (FOUR_C_ENABLE_IWYU)
157+ find_program (FOUR_C_IWYU_EXECUTABLE NAMES include -what-you-use iwyu)
158+ if (NOT FOUR_C_IWYU_EXECUTABLE)
159+ message (
160+ FATAL_ERROR "Option FOUR_C_ENABLE_IWYU is ON but include-what-you-use/iwyu is not found."
161+ "You can specify the path in the CMake variable FOUR_C_IWYU_EXECUTABLE."
162+ )
163+ endif ()
164+ endif ()
165+
155166##
156167# Optimization flags
157168# These flags are reasonable defaults. Users may amend them by setting FOUR_C_CXX_FLAGS and/or FOUR_C_CXX_FLAGS_<CONFIG>.
You can’t perform that action at this time.
0 commit comments