Search code examples
qtqmake

How to get platform dependent output filename with QMake?


Assume I have a qmake project file *.pro:

# some stuff ...

TARGET = my_binary

# other stuff...

include( $$PWD/post.pri )

And inside the post.pri file (because I would like to reuse whatever this *.pri file does), I would like to get the complete name of the output file.

For example if is an app, then on windows I would like to get my_binary.exe and on linux my_binary. Or if the project is a shared lib, I would like to get my_binary.dll or libmy_binary.so respectively. Same if is a static lib, I would expect my_binary.lib and libmy_binary.a.

I have already tried the undocumented qmake variable QMAKE_FILE_OUT but with no success.


Solution

  • You can do this in your .pro script:

    load(resolve_target)
    message($$QMAKE_RESOLVED_TARGET)
    

    It will output the build path and target name, according to your platform and project TEMPLATE.