CMake add_custom_command未在运行 [英] CMake add_custom_command not being run

查看:564
本文介绍了CMake add_custom_command未在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 add_custom_command 以在构建期间生成文件。该命令似乎没有运行,所以我做了这个测试文件。

  cmake_minimum_required(VERSION 2.6)

add_custom_command(
OUTPUT hello.txt
COMMAND touch hello.txt
DEPENDS hello.txt

我试过运行:

  cmake。 
make

并没有生成hello.txt。

$ p

<$ p

$ p> add_custom_target(run ALL
DEPENDS hello.txt)

如果你熟悉makefiles,这意味着:

  all:run 
run:hello.txt


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
)

I tried running:

cmake .  
make

And hello.txt was not generated. What have I done wrong?

解决方案

Add the following:

add_custom_target(run ALL
    DEPENDS hello.txt)

If you're familiar with makefiles, this means:

all: run
run: hello.txt

这篇关于CMake add_custom_command未在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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