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.