Adding custom target in qmake

旧城冷巷雨未停 提交于 2019-12-21 22:20:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/35847243/adding-custom-target-in-qmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!