我想做一些事情add_custom_command
,输出文件名作为生成的makefile中的目标.这样做有一种优雅的方式吗?
我见过的所有示例(例如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)
Run Code Online (Sandbox Code Playgroud)
但是,生成的makefile中的目标名称bin
不是hello.bin
.有没有办法让hello.bin
自己成为生成的makefile中的目标?
我试过的一些解决方案不起作用:
add_custom_target(hello.bin ALL DEPENDS hello.bin)
导致makefile中出现循环依赖关系.cmake ×1