如何从 CMake 或 make 输出编译依赖项?
我有一个 CMake C++ 项目,该项目正在快速增长且经常变化。我正在努力将编译时间减少到最低限度。
通常,当我重建项目时,尤其是在标头更改之后,我对需要重新编译的编译单元数量感到惊讶。我正在尝试识别可以避免的#include,例如通过使用预声明或不在标头中内联简单函数。
有什么方法可以从 CMake 本身、生成的 Makefile 或直接从文件本身找出哪些单元依赖于哪些标头?
一个列表会很好,一个可视化图表(graphviz? )更好。谷歌没有为我找到任何结果。 CMake 有 --graphviz
选项,但它在目标上运行,而不是单个编译单元。
跨平台的东西(即仅使用 CMake)是首选,但我也会选择仅 Linux。
I have a CMake C++ project that is rapidly growing and often changing. I'm trying to reduce compile times to a minimum.
Often, when I rebuild the project, especially after a header change, I'm surprised at how many compilation units need to be recompiled. I'm trying to identify #include
s that can possibly be avoided, for example by using pre-declarations or by not inlining trivial functions in headers.
Is there any way to find out, from CMake itself, from the generated Makefile, or directly from the files themselves, which units depend on which headers?
A list would be nice, a visual graph (graphviz?) even nicer. Google turns up nothing for me. CMake has the --graphviz
option, but it operates on targets, not individual compilation units.
Something cross-platform (i.e. using just CMake) is preferred, but I'll settle for Linux-only too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我使用基于 gcc 的工具链时,我发现 cmake2.8(运行 make 后)生成的依赖项信息存在于
depend.make
和depend.internal
文件中。使用VS似乎不会生成这样的文件(但这对你来说似乎不是问题)。此外,这些文件是 cmake 内部文件,因此使用它们需要您自担风险。I found the dependency information generated by cmake2.8 (after running make) living in
depend.make
anddepend.internal
files, when I'm using a gcc based toolchain. Using VS does not seem to generate such files (but this doesn't seem to be a problem for you). Also these files are cmake internals, so use them at your own risk.