Get qmake to execute shell script after build finished on Mac

Galadrius Krunthar picture Galadrius Krunthar · Jun 10, 2011 · Viewed 7.1k times · Source

After my release build is finished I would like to run a script.

I found this question How to execute shell command after compile finished from .pro in QT? but the answer doesn't work for me. I tried adding various modifications of this to my .pro file:

CONFIG(release, debug|release) {
    mytarget.target = ./MyScript.sh
    mytarget.commands = touch $$mytarget.target

    QMAKE_EXTRA_TARGETS +=mytarget
    QMAKE_POST_LINK += mytarget
}

But this always results with ":-1: error: mytarget: No such file or directory". Path is correct and 'MyScript.sh' works fine from command line.

Since this works for other people I guess I’m doing something wrong. I use Qt 4.7.2 on Mac.

Answer

Alessandro Pezzato picture Alessandro Pezzato · Jun 10, 2011

Path is relative to build directory. If your script is not in your build directory,you have to change path. Try using ../MyScript.sh

Why are you using target? If your only intent is to execute MyScript.sh after the build, you need only

QMAKE_POST_LINK += ./MyScript.sh