Important: Please read the Qt Code of Conduct -

Accessing qmake DESTDIR variable in code

  • Hey,

    I was wondering if there's anyway to access the qmake DESTDIR variable in my C++ code.

    I'm currently defining my own macro using this variable, but wanted to know if there's a built in Qt way:
    DEFINES += DEST_DIR=\\\"$${DESTDIR}\\\"

  • Lifetime Qt Champion


    No there's not except the way you do it.

    Why do you need that value in your code ?

    Edit: you could generate a header file with the content of that variable but better understand your need before doing that.

  • We place all of our compiled libs and apps in our own custom dir, rather than having them spread across each individual lib/project folder.

    We also have a plugin architecture, and plugins are placed in a plugins dir inside the above referenced dir.

    These plugins are shared across a bunch of different apps. So when I load the plugins in our app code, I want to be able to find the plugins subdir to load from. Note that this is only for development. When generating Mac dmg bundles, we deal with pulling these plugins into the bundle.

    Am I approaching this incorrectly?

  • Lifetime Qt Champion

    @SGaist said in Accessing qmake DESTDIR variable in code:

    Why do you need that value in your code ?

    Esp. since it can be overwritten during make install...

  • Lifetime Qt Champion

    In that case, you should rather structure your DESTDIR content to match more closely the final output when packaging your application.

    That way, you don't have to do special handling in your code. Just in your project management.

  • Ok, I will try to restructure our stuff towards that, but I don't want to impact other developers too much, plus this is how they've been doing it forever.

    For now it seems my method is working OK.

    Thanks for the help.

Log in to reply