Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute shell command after compile finished from .pro in QT?

Tags:

What changes must I make to the .pro file if I want to execute chmod command, execute the output binary file, or do some other operations.

like image 999
camino Avatar asked May 10 '11 07:05

camino


2 Answers

I had a similar problem. I wanted a special tool (versioner) to run over the code every time the Makefile was executed. Here's the solution:

(to be read in the Qmake Manual, Configuring qmake's Environment, Section: Customizing Makefile Output)

Create you own Makefile target. Specify the command etc.

mytarget.target = .buildfile
mytarget.commands = touch $$mytarget.target

QMAKE_EXTRA_TARGETS += mytarget

This way, you have an extra target you can call with make mytarget for example. If you want to tie it together to the actual buildtarget you'll have to add:

POST_TARGETDEPS += mytarget

Hope that helps.

Best regards
D

like image 139
Dariusz Scharsig Avatar answered Sep 28 '22 22:09

Dariusz Scharsig


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, and target_pre and target_post some custom targets. Now make 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.

like image 44
ephemerr Avatar answered Sep 28 '22 22:09

ephemerr