0
votes

I can easily edit Makefile to add custom step. For example, I have a line:

first: release

If I change it to

first: pre-build release

Then I'll be able to place some operations after "pre-build:" label.

The question is how to write corresponding instruction to .pro file, to force qmake tool generate required lines in Makefile?

1

1 Answers

1
votes

You can add a custom target to your resulting Makefile using QMAKE_EXTRA_TARGETS variable, kind of that:

QMAKE_EXTRA_TARGETS += beforebuild
beforebuild.commands = echo Hello world!
beforebuild.CONFIG = phony

However, you cannot put this target onto first: all line, unless you've patched qmake's source code (consider the following snippet from makefile.cpp: t << "first: " << targets.first()->target << endl).

In principle, it's possible to induce some dependency between all (or release / debug) and your beforebuild target, so beforebuild would still get executed by make automatically, as described in this article (Russian language). Yet the resulting solution seems to me too ugly and error-prone.

I think that simply executing make beforebuild first (probably, using a shell script) is much easier. Unless you're using Qt Creator, in this case you should try the recipe from the link above.