Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to separate release and debug builds in Qt?

Tags:

c++

qt4

qmake

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...

like image 888
sorush-r Avatar asked Feb 17 '23 03:02

sorush-r


1 Answers

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...

like image 164
Michael Wild Avatar answered Feb 28 '23 00:02

Michael Wild