我想将发布和调试版本的二进制文件放在源代码旁边的不同文件夹中。在.pro文件中:
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
}
对于发布版本,一切都很好。我在项目的根目录中有一个./release目录。但是对于调试版本,qmake没有创建调试目录,它的名字是release
(再次!):
qmake CONFIG+=debug CONFIG+=local
// generates release and put everything in that directory
// but I want debug directory !
更新
替换调试和发布的顺序,制作调试目录。 qmake只能看到最后的配置...
答案 0 :(得分:5)
如果您真的需要进行源内构建并拥有单独的输出目录,我认为您需要将documentation的条件更改为
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
}
但是,不要问我为什么。恕我直言QMake是一个可憎的,应该不惜一切代价避免...
答案 1 :(得分:3)
真正的解决方案是进行源外构建。这样,每次从调试到发布构建和返回时,都不必重新配置。这样做,使用以下内容:
mkdir build-dbg
cd build-dbg
qmake ../foo.pro CONFIG+=debug
cd ..
mkdir build-rel
cd build-rel
qmake ../foo.pro CONFIG+=release
作为额外的加分,您不会使用构建碎片污染源树。