Running a script post Qt build

Just sometimes you want/need to run a script after building your application to modify the output in some way (copy resources into a bundle for example). Qt of course has a way of doing this which I just discovered. I need to modify a Mac OSX bundle’s Info.plist file after compilation (I’ll explain why in my next post) and if I don’t automate it, I’ll just forget and spend hours trying to work out what I’ve (not) done! So, add the following to your Qt project file:

QMAKE_POST_LINK += $$quote($${PWD}/fix_plist.sh $${OUT_PWD} $${TARGET})

All fields that start with $$ are macros that Qt will replace with the relevant information. The $$quote bit just makes sure the command is appropriately quoted for the target OS. $${PWD} is the projects working directory where the application’s source (and my script fix_plist.sh lives), $${OUT_PWD} is the build output directory where the output bundle will live and $${TARGET} is the name of the application. The last two are passed to my script as command line arguments so I can find the app bundle and thus its Info.plist by relative path.

Share:
Facebook
Twitter
Google+
http://www.gulon.co.uk/2015/10/22/running-a-script-post-qt-build/
RSS
Follow by Email
SHARE

Leave a Reply

Your email address will not be published. Required fields are marked *