c语言文件名称自定义,cmake – 使用文件名作为目标添加自定义命令

我想用输出文件做add_custom_command之类的事情

name作为生成的makefile中的目标.有一种优雅的方式

这样做?

我见过的所有示例(例如the CMake FAQ re: latex)都使用add_custom_command来告诉如何生成所需的输出文件,然后使用add_custom_target来创建目标.例如.:

add_executable (hello hello.c)

add_custom_command(OUTPUT hello.bin

COMMAND objcopy --output-format=binary hello hello.bin

DEPENDS hello

COMMENT "objcopying hello to hello.bin")

add_custom_target(bin ALL DEPENDS hello.bin)

但是,生成的makefile中的目标名称则为bin

比hello.bin.有没有办法让hello.bin本身成为目标

在生成的makefile中?

我试过的一些解决方案不起作用:

>更改为:add_custom_target(hello.bin ALL DEPENDS hello.bin)会在makefile中产生循环依赖关系.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值