如何从命令行列出已定义的制造目标? [英] How do I list the defined make targets from the command line?

查看:78
本文介绍了如何从命令行列出已定义的制造目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问这个问题我觉得很傻,但是我在这个问题上找不到任何东西。

I feel almost silly for asking this but I couldn't find anything on this...

假设我有一个包含多个目标的cmake项目:库,可执行文件,外部目标...。如何使用cmake命令行界面列出它们。我想要一个有效的东西列表来代替 $ target 到以下命令行中。

Suppose I have a cmake project containing a number of targets: libraries, executables, external targets, ... . How do I list them using the cmake command line interface. I want a list of things that are valid to substitute for $target into the following command line.

cmake . && cmake --build . --target $target

全部奖励积分,用于使用既没有grep也没有找到,也没有python或perl也没有...-您明白了。

Lot's of bonus points for a solution that uses neither grep nor find nor python nor perl nor ... - you get the idea.

推荐答案

对于Makefile生成器构建环境,您可以使用

For Makefile generator build environments you could use

cmake --build . --target help

还有图形输出解决方案(示例见此处):

And there is the graphical output solution (example found here):

cmake --graphviz=test.graph 
dotty test.graph

另请参见使用CMake生成依赖图 CMake Graphviz输出清洁程序

如果您没有安装 dotty ,仍然可以通过启用 GLOBAL_DEPENDS_DEBUG_MODE 在您的 CMakeLists.txt

If you don't have dotty installed, you can still make the target dependencies visible with enabling GLOBAL_DEPENDS_DEBUG_MODE in your CMakeLists.txt:

set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)

此处的缺点是您无法从命令行触发它。生成make环境时,它将始终显示在 stderr 上。

The disadavantage here is that you can't trigger it from the command line. It will always show on stderr when generating the make environment.

参考

  • How can I get the list of dependencies of cmake target?
  • Internet Archive: "CMake: list of targets"

这篇关于如何从命令行列出已定义的制造目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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