6

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.

Community
  • 1
  • 1

1 Answers1

8

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
Alessandro Pezzato
  • 8,603
  • 5
  • 45
  • 63
  • I'll try it (can't right now) but I don't think that's the issue. “MyScript.sh” sits on the same level as my Forms directory, which contains a few header files used elsewhere. Since "INCLUDEPATH += ./Forms" seems to be doing its job I assume "./MyScript.sh" is correct. – Galadrius Krunthar Jun 10 '11 at 00:20
  • if you want to be sure about it, try writing: "QMAKE_POST_LINK = pwd". – Alessandro Pezzato Jun 10 '11 at 07:00
  • @Galadrius Krunthar: the INCLUDEPATH variable will change the include paths sent to the compiler for looking up header files. It won't change where the makefile looks for related files - you have to put the path in for those by hand. – Caleb Huitt - cjhuitt Jun 12 '11 at 14:53
  • I fixed the path and used just QMAKE_POST_LINK without target and then it finally worked. – Galadrius Krunthar Jun 14 '11 at 23:33