c++ - 如何在 Qt 中分离发布和调试版本?

标签 c++ qt4 qmake

我想将发布和调试版本的二进制文件放在源代码旁边的不同文件夹中。在 .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 只能看到最后的配置...

最佳答案

如果您真的必须进行源代码内构建并具有单独的输出目录,我认为您需要根据 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 是一种可憎的东西,应该不惜一切代价避免......

关于c++ - 如何在 Qt 中分离发布和调试版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15499411/

相关文章:

c++ - 透明地操作插入 ostream 的字符串

c++ - 当向其添加子选项卡时,如何使 qtabwidget 实例自动调整大小?

c++ - 在 Mingw 64 位上使用 Clang

c++ - QT Creator 将 SQLite 复制为空数据库

linux - 在 qmake (5.0) 生成的 Makefile 中设置 LINK 变量

c++ - 在两个窗口中连接到相同的信号

c++ - 我得到的掩护问题为 "Wrapper object use after free (WRAPPER_ESCAPE)"

c++ - CMake 问题 : could not find any instance of Visual Studio

c++ - 一种在 Qt 中管理 GUI 状态的 RAII

c++ - 需要在 C++ 中使用 Qt 4.7 创建 http 网络服务器