include-what-you-use not running as part of the build
cmake --version
: cmake version 3.15.2
I have a CmakeLists.txt file configured to run include-what-you-use
by setting CMAKE_CXX_INCLUDE_WHAT_YOU_USE
.
find_program(IWYU include-what-you-use DOC "Path to the include-what-you-use tool")
if (IWYU)
add_feature_info(include-what-you-use IWYU "Tool to analyze #include usage")
list(APPEND IWYU -Xiwyu;any;-Xiwyu;iwyu;-Xiwyu;args)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU})
else ()
message("Install include-what-you-use to enable the tool")
endif ()
When I perform a build, I do not see any output from include-what-you-use
. I have printed CXX_INCLUDE_WHAT_YOU_USE
to confirm that the property is set on the target.
If I run the iwyu-tool
instead, I do see output.
find_program(IWYU iwyu-tool DOC "Path to the include-what-you-use tool")
if (IWYU)
add_feature_info(include-what-you-use IWYU "Tool to analyze #include usage")
add_custom_command(TARGET
${PROJECT_NAME}.elf
POST_BUILD
VERBATIM
COMMENT "Running include-what-you-use"
COMMAND "${IWYU}" "-p" ".")
else ()
message("Install include-what-you-use to enable the tool")
endif ()
Why is the method of setting the CXX_INCLUDE_WHAT_YOU_USE
property not causing the tool to be run?