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

查看:49
本文介绍了如何获取 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天全站免登陆