Changing release and debug build folders of a Qt application

I’m using QtCreator as an IDE for Qt based projects. Generally I’m happy with it, but default project build settings are somewhat different from my expectations.

QtCreator, creates separate build directories for Debug and Release configuration in parent directory of the project. For example if your project name is libAAA, it will create following folders in parent directory:

  • build-libAAA-Desktop-Debug
  • build-libAAA-Desktop-Release

I want to make Release builds in the same directory where the sources codes living and Debug builds must be a new Debug subfolder.

How can I make this changes within project’s .pro file?

You can use following settings in your .pro file:

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

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

With above configuration, output of the release builds will remain in the source code directory. All the generated temprorary object codes will be in .obj, .moc, .rcc and .ui hidden directories.

Debug builds are also have similar folders with the difference of debug subfolder.