4
votes

I would like to put binaries of release and debug build in different folders beside source code. in .pro file:

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

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

For release builds everything is good. I have a ./release directory in root of project. But for debug build, qmake didn't create a debug directory, it's name is release (again!):

qmake CONFIG+=debug CONFIG+=local 
// generates release and put everything in that directory
// but I want debug directory !

Update:

Replacing order of debug and release, makes debug directory. Only last config is seen by qmake...

2
Doesn't this happen automatically? For me it does - I get different builds in separate directory in the same path as the project folder.dtech
@ddriver You're probably on Windows...sorush-r
Yep, I guess it is different in Linux.dtech

2 Answers

5
votes

If you really have to do in-source builds and have separate output directories, I think you need to change your conditionals per documentation to

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

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

Don't ask me why, though. IMHO QMake is an abomination that should be avoided at all cost...

3
votes

The real solution is to do out-of-source builds. That way you don't have to reconfigure every time you switch from debug to release build and back. Do do this, use the following:

mkdir build-dbg
cd build-dbg
qmake ../foo.pro CONFIG+=debug
cd ..
mkdir build-rel
cd build-rel
qmake ../foo.pro CONFIG+=release

As an added plus you don't pollute the source tree with build debris.