This is for setting up the application bundle of a MacOSX app. I have a script which copies a few files and does some other things. So I want to execute the script after the
I've scratched my head about this for a few man-days over the past several months, and I haven't yet found a "pure" solution. However, FWIW, if you don't mind the hack of forcing relink every time, here's how to do that:
(This implementation of "post-build-events" is similar to this implementation of "pre-build-events".)
Caveats:
Works only for projects that have a linking step, so, not
TEMPLATE=aux
or TEMPLATE=subdirs
.
FORCELINK_CPP_FILE = force_link.cpp
#This batch of statements causes the dummy file to be touched each build.
forcelink.target = $$FORCELINK_CPP_FILE
#FORCE is a nonexistent target, which will cause Make to always re-execute the recipe.
forcelink.depends = FORCE
forcelink.commands = touch $$FORCELINK_CPP_FILE
QMAKE_EXTRA_TARGETS += forcelink
#This statement ensures that touching the above file at Make time will force relinking.
SOURCES += $$FORCELINK_CPP_FILE
#QMake will complain unless the file actually exists at QMake time,
# too, so we make sure it does.
#I used to touch this on QMake build_pass runs, too,
# but it caused transient access-denied errors.
# I guess the release and debug makefiles are generated in parallel.
!build_pass : write_file($$FORCELINK_CPP_FILE)
There is related questions there and there. I quote my answer for first of them:
Another way to make things in given order is to use empty "super" target:
super.depends = target_pre first target_post QMAKE_EXTRA_TARGETS += super
Where
first
- is default qmake target, andtarget_pre
andtarget_post
some custom targets. Nowmake super
just do the thing.
EDIT: looks like in last versions of Qt build of dependencies is running in paralell so this solution wouldn't work.