在qmake中添加自定义目标 [英] Adding custom target in qmake

查看:114
本文介绍了在qmake中添加自定义目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用qmake来构建我的资源,如下所示[Qt 5.5]:

imageTarget.target = images.rcc
imageTarget.depends = $$PWD/images.qrc
imageTarget.commands = rcc -binary -no-compress $$PWD/images.qrc -o $$OUT_PWD/images.rcc
QMAKE_EXTRA_TARGETS += imageTarget

当我为我的.pro文件运行qmake时,它将为目标images.rcc目标生成生成规则:

images.rcc: /path/to/images.qrc
rcc -binary -no-compress /path/to/images.qrc -o /output/path/to/images.rcc

到目前为止一切都很好.

但是,我希望运行qmake也会生成输出文件images.rcc,但不会.

但是当我进入makefile目录并键入命令"make images.rcc"时,就会生成images.rcc.我错过了一点吗?如何在qmake步骤中定位目标而无需额外的make?

解决方案

使用

QMAKE_EXTRA_TARGETS += imageTarget

您只是定义了一个新目标-但是在运行make时不会自动构建该目标.

尝试添加

PRE_TARGETDEPS += images.rcc

如果images.qrc已更改,则在运行make时,这应该会自动构建一个新的images.rcc.

I want to build my resources with qmake as follows [Qt 5.5]:

imageTarget.target = images.rcc
imageTarget.depends = $$PWD/images.qrc
imageTarget.commands = rcc -binary -no-compress $$PWD/images.qrc -o $$OUT_PWD/images.rcc
QMAKE_EXTRA_TARGETS += imageTarget

When I run qmake for my .pro file, it generates the make rule for target images.rcc target as expected:

images.rcc: /path/to/images.qrc
rcc -binary -no-compress /path/to/images.qrc -o /output/path/to/images.rcc

So far so good.

However, what I would expect is that running qmake would also generate the output file images.rcc and it does not.

But when I go into the makefile directory and type in the command "make images.rcc", then the images.rcc is generated. Am I missing a point? How can I make target in the qmake step without the need of extra make?

解决方案

With

QMAKE_EXTRA_TARGETS += imageTarget

you just define a new target - but it is not automatically built when running make.

Try to add

PRE_TARGETDEPS += images.rcc

This should automatically build a new images.rcc when running make if images.qrc has changed.

这篇关于在qmake中添加自定义目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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