qmake 运行命令只能在调试模式下,如何?
qmake run command only in debug mode, how?
这是 的延续。我要运行
win32:LIBS ~= s/-l(.*)/-ld/g
仅适用于调试版本,因为想法是在调试模式下将 d
附加到库名称。
我试过了
win32:debug:LIBS ~= s/-l(.*)/-ld/g
但它也在发布模式下执行。
我通常就是这样做的:
CONFIG(debug, debug|release) {
unix: TARGET = $$join(TARGET,,,d)
win32: TARGET = $$join(TARGET,,,d)
}
存在平台是因为最初我想对不同的平台使用不同的约定,这里只是作为示例
您可以在为 libs/apps
设置目标名称后立即添加此规则
正常布局在 .pro 文件中有这个规则来生成你的库和类似的东西:
CONFIG(debug, debug|release) {
unix: LIBS += -L../libs -L../../libs -lyourlibnamed
win32: LIBS += -L../libs -L../../libs -lyourlibnamed
} else {
unix: LIBS += -L../libs -L../../libs -lyourlibname
win32: LIBS += -L../libs -L../../libs -lyourlibname
}
在 .pri 文件中
您需要使用 CONFIG(debug, debug|release)
而不是 debug
的简单测试。 CONFIG
变量很特殊,因为它可以包含多个 debug
和 release
条目,但只有 最后一个才算 .
因此,即使在发布模式下,您的 CONFIG 可能看起来像 something, debug, something, release
: release
"wins" 因为它是最后一个,但范围测试不知道这一点。
这是 qmake 的一个怪癖。它甚至被记录在案,如果你知道先看哪里:/
As the order of values is important in CONFIG variables (that is, the last one set will be considered the active config for mutually exclusive values) a second parameter can be used to specify a set of values to consider. For example:
这是
win32:LIBS ~= s/-l(.*)/-ld/g
仅适用于调试版本,因为想法是在调试模式下将 d
附加到库名称。
我试过了
win32:debug:LIBS ~= s/-l(.*)/-ld/g
但它也在发布模式下执行。
我通常就是这样做的:
CONFIG(debug, debug|release) {
unix: TARGET = $$join(TARGET,,,d)
win32: TARGET = $$join(TARGET,,,d)
}
存在平台是因为最初我想对不同的平台使用不同的约定,这里只是作为示例
您可以在为 libs/apps
设置目标名称后立即添加此规则正常布局在 .pro 文件中有这个规则来生成你的库和类似的东西:
CONFIG(debug, debug|release) {
unix: LIBS += -L../libs -L../../libs -lyourlibnamed
win32: LIBS += -L../libs -L../../libs -lyourlibnamed
} else {
unix: LIBS += -L../libs -L../../libs -lyourlibname
win32: LIBS += -L../libs -L../../libs -lyourlibname
}
在 .pri 文件中
您需要使用 CONFIG(debug, debug|release)
而不是 debug
的简单测试。 CONFIG
变量很特殊,因为它可以包含多个 debug
和 release
条目,但只有 最后一个才算 .
因此,即使在发布模式下,您的 CONFIG 可能看起来像 something, debug, something, release
: release
"wins" 因为它是最后一个,但范围测试不知道这一点。
这是 qmake 的一个怪癖。它甚至被记录在案,如果你知道先看哪里:/
As the order of values is important in CONFIG variables (that is, the last one set will be considered the active config for mutually exclusive values) a second parameter can be used to specify a set of values to consider. For example: