如何获得cmake目标的依赖关系列表? [英] How can I get the list of dependencies of cmake target?

查看:1219
本文介绍了如何获得cmake目标的依赖关系列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我如何知道我的可执行目标E是否依赖于我的库目标L?

For instance, how can I know if my executable target E depends on my library target L?

让我们的图像E取决于L1和L2,不知道他们是否依赖L。

Let's image E depends on L1 and L2, but I don't know if they depend on L.


target_link_libraries(E L1 L2)

target_link_libraries(E L1 L2)



在调用target_link_libraries之前,我想从cmake本身获取列表,这样我可以做一些技巧,如果我检测到E取决于两个不兼容的库。我使用GetPrerequisites播放了一些,但是这发现了对磁盘上的现有库的依赖,而不是正在构建的目标库。

I'd like to get the list from cmake itself before calling target_link_libraries, so that I can do some tricks if I detect that E depends on two libraries which are incompatible. I played a bit with GetPrerequisites, but this finds out dependencies on existing libraries which are on disk, not on target which are being built.

感谢

推荐答案

您可以使用CMake的依赖图生成器。请阅读此链接,了解详情

You can use CMake's "dependency graphs generator". Please read this link for details

cmake --graphviz=test.dot . ...

这篇关于如何获得cmake目标的依赖关系列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆