CMake add_custom_command 未运行 [英] CMake add_custom_command not being run
本文介绍了CMake add_custom_command 未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 add_custom_command在构建过程中生成一个文件.该命令似乎从未运行过,所以我制作了这个测试文件.
I'm trying to use add_custom_command to generate a file during the build. The command never seemed to be run, so I made this test file.
cmake_minimum_required( VERSION 2.6 )
add_custom_command(
OUTPUT hello.txt
COMMAND touch hello.txt
DEPENDS hello.txt
)
我试过跑步:
cmake .
make
并且 hello.txt 没有生成.我做错了什么?
And hello.txt was not generated. What have I done wrong?
推荐答案
添加以下内容:
add_custom_target(run ALL
DEPENDS hello.txt)
如果您熟悉 makefile,这意味着:
If you're familiar with makefiles, this means:
all: run
run: hello.txt
这篇关于CMake add_custom_command 未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文