Important: Please read the Qt Code of Conduct -

How to specify TARGET full path in QMAKE_POST_LINK?

  • To run post-processing tool with QMAKE_POST_LINK, I need to specify full path to the target file. The best I can do so far is

    QMAKE_POST_LINK = Post-Process-Tool "$${DESTDIR}/$${TARGET}.exe"

    but I'm looking for generalized solution (output file can have different extensions)
    Thanks in advance,

  • Not sure if this is the best solution, but it might be enough for you:

    QMAKE_POST_LINK = Post-Process-Tool $$shell_quote($${DESTDIR}/$${TARGET}$$join(TARGET_EXT,,.))

    Here I've used $$join so that the . separator only appears if the file extension is non-empty.

    Also $$shell_quote may or may not be necessary if the path contains spaces, etc.


  • Unfortunately the above solution didn't work for me, $${TARGET_EXT} appears empty.

    BTW, the entire concept of building full path to the output file "by hand" appears to be limited. For instance, with TARGET=MyModule and TEMPLATE=lib, the output file is MyModule.dll on Windows but on Linux, so simple concatenation just doesn't work.

    It has to be a better way to pickup complete full path to the target file. QMAKE_RESOLVED_TARGET from mkspecs/features/resolve_target.prf seems to be a good candidate, but I'm failing to extract its value: it appears empty when I try to use it in QMAKE_POST_LINK.

    Qt community, please advise. Inability to specify arguments for post link step becomes a (very unexpected) shortcoming of qmake system and blocks our entire project.

Log in to reply