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}/ $${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 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.

Follow by Email

Leave a Reply

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