Search code examples
c++qtprojects-and-solutions

Change building directory in .pro


How can i change building directory in qt project file? I tried this:

TARGET = project
win32: {
    CONFIG(release, debug|release): DLLDESTDIR +=  $$PWD/../lib
}
unix: {
    CONFIG(release, debug|release): QMAKE_POST_LINK += $$quote(cp project $$PWD/../lib)
}

But this didn't give result :(

Found something a bit similar: DESTDIR parameter. However, this option is only responsible for executables. And how to transfer all the files?


Solution

  • Thanks to @BNT for the help.

    CONFIG(debug, debug|release) {
      DESTDIR = $$PWD/../debug/lib
    } else {
      DESTDIR = $$PWD/../lib
    }
    
    OBJECTS_DIR = $${DESTDIR}/.obj
    MOC_DIR = $${DESTDIR}/.moc
    RCC_DIR = $${DESTDIR}/.rcc
    UI_DIR = $${DESTDIR}/.ui
    

    Where DESTDIR is the folder for the executable.

    But the Makefile in such a way not to move. It has a dedicated constant, and in the documentation, as @BNT already noticed, it is written:

    Note: Do not attempt to overwrite the value of this variable.