如何使用 cmake --build 构建多个目标 [英] How can I build multiple targets using cmake --build

查看:34
本文介绍了如何使用 cmake --build 构建多个目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CMake 构建,其中包含一堆不同的目标 ABC 等.外部应用程序的任务是构建,目前通过调用

I have a CMake build with a bunch of different targets A, B, C, etc. An external application is tasked with building, and currently does so by calling

cmake --build .

然而,这构建了所有目标,有时我只想构建一个子集,比如AB而不是C.--target 标志只能给出一次,并且只接受一个目标.

However, this builds all targets, and sometimes I only want to build a subset, like A and B but not C. The --target flag can only be given once, and only accepts a single target.

我想我可以让 CMake 生成适当的 Makefile,然后显式调用 make AB,但这会带走 cmake --build 成为构建系统的好处不可知论者.

I guess I could let CMake generate the appropriate Makefile, and then call make A B explicitly, but that takes away the nice thing about cmake --build being build system agnostic.

有什么好的方法可以解决这个问题吗?

Is there a nice way to solve this?

推荐答案

CMake 3.15 版添加了对此功能的支持.只需在命令行上列出所有目标,如下所示:

CMake version 3.15 added support for this feature. Simply list all targets on the command line as follows:

cmake --build . --target Library1 Library2

这篇关于如何使用 cmake --build 构建多个目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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