Search code examples
qtqmake

QMake: Get full path of output executable


In my .pro file for QMake I would like to run install_name_tool to replace some library paths. For this I need to determine path to my output executable. Particularly on macx the path to executable looks like this

<build_directory>/<configuration_name>/<target_name>.app/Contents/MacOS/<target_name>

I figured out that

message("build_directory=$${OUT_PWD}")
message("target_name=$${TARGET}")

Is there a QMake variable to populate configuration_name?

By default it is supposed to return "release" for release configurations and "debug" for debug configurations. From what I saw online people just explicitly define $${DESTDIR}

debug { DESTDIR = debug }
release { DESTDIR = release }
debug_and_release { DESTDIR = bin }

if not defined message("DESTDIR=$$DESTDIR") returns empty value for DESTDIR.


Solution

  • This works:

    CONFIG(debug, debug|release) {
        DEBUG_OR_RELEASE = debug
    }  else {
        DEBUG_OR_RELEASE = release
    }
    

    So then the full output path is:

    $${OUT_PWD}/$${DEBUG_OR_RELEASE}