如何在我的CMake项目中自动应用include-what-you-use中的建议?

时间:2017-01-19 18:50:11

标签: c++ cmake

感谢this answer,我了解到我可以通过在CMake中使用以下内容在我的C ++项目上运行include-what-you-use

set_property(TARGET ${target_name}
             PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})

这会在我对项目运行cmake --build时输出有关包含内容的建议:

Warning: include-what-you-use reported diagnostics:

/home/user/hello/main.cc should add these lines:

/home/user/hello/main.cc should remove these lines:
- #include <vector>  // lines 2-2

The full include-list for /home/user/hello/main.cc:
#include <iostream>  // for operator<<, basic_ostream, cout, endl, ostream

include-what-you-use documentation说明了如何自动应用这些建议,以便我始终可以使用include-what-you-use指定的“完整包含列表”:

make -k CXX=/path/to/llvm/Debug+Asserts/bin/include-what-you-use > /tmp/iwyu.out
python fix_includes.py < /tmp/iwyu.out

使用CMake CXX_INCLUDE_WHAT_YOU_USE属性时,有没有办法自动应用建议?如果没有,有没有办法可以将建议作为我的CMake构建的一部分来应用?

0 个答案:

没有答案