【问题标题】:How to set different qmake configuration depending on debug / release?如何根据调试/发布设置不同的 qmake 配置?
【发布时间】:2011-02-27 16:11:00
【问题描述】:

我需要在我的 .pro 文件中为调试和发布版本指定不同的输出和中间文件夹。我创建了以下测试 .pro 文件:

release {
  message( "release" )
}
debug {
  message( "debug" )
}

但是在 Qt Creator 中使用“调试”构建编译这个 .pro 文件会导致以下输出:

Project MESSAGE: release
Project MESSAGE: debug

似乎“调试”和“发布”条件都设置为TrueO_O。是否可以在 qmake 中以某种方式分别处理调试和发布版本?

【问题讨论】:

标签: qt


【解决方案1】:

根据the qmake manual

CONFIG(release, debug|release) {
  message( "release" )
}
CONFIG(debug, debug|release) {
  message( "debug" )
}

不过,我真的不明白这个解释。看来这两个选项都真的被选中了,而且只有一个是“活动的”。但是 qmake 以反直觉的东西而闻名。

【讨论】:

  • 查看this问题及其答案以获得解释。
【解决方案2】:

试试:

CONFIG(debug, debug|release){
message("debug")
} else {
message("release")
}

如果您在debugdebug|release 模式下构建项目,qmake 将显示“调试”,否则(即:如果您在release 模式下构建项目)“发布”消息将显示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2020-06-17
    • 2011-01-02
    • 2010-09-13
    • 2011-06-04
    相关资源
    最近更新 更多