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

后端 未结 4 724
醉话见心
醉话见心 2020-12-01 12:40

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.

4条回答
  •  悲&欢浪女
    2020-12-01 13:04

    The right answer depends on exactly what you want, and when. However, as seen in some previously posted comments here QMAKE_POST_LINK is probably what you want rather than POST_TARGETDEPS.

    Check out this related post: QMake: execute script after build

    For one, when you use POST_TARGETDEPS that fires off BEFORE your exe is created (in Windows) or BEFORE it is recreated (in Linux)! QMake works differently depending upon the platform and the complier.

    I needed to do some "symbols processing" on an exe when it was recompiled. POST_TARGETDEPS gave me problems in both Windows (using mingw) and Linux (using gcc). In Windows, it executed my script prematurely, and in Linux it overwrote my exe after I had modified it (i.e. added back my debugging info to the exe after I had stripped it in my external script). QMAKE_POST_LINK worked perfectly, however, in both cases. It's also short, sweet, and more clear by comparison!

提交回复
热议问题