Qmake处于发布和调试模式 [英] Qmake in release and debug mode
问题描述
我有一个图书馆,我希望它根据自己所处的配置(调试或发行版)将自身复制到目录中。这是我的项目文件。
I have a library and I would like it to copy itself to a directory depending upon what configuration i'm in (debug or release). Here is my project file.
#-------------------------------------------------
#
# Project created by QtCreator 2011-08-13T12:48:33
#
#-------------------------------------------------
TARGET = JECLibrary
TEMPLATE = lib
DEFINES += JECLIBRARY_LIBRARY
SOURCES += \
JECMessageText.cpp \
JECMessageCombo.cpp \
JECButton.cpp
HEADERS +=\
JECLibrary_global.h \
JECMessageText.h \
JECMessageCombo.h \
JECButton.h
CONFIG(debug, debug|release)
{
DLLDESTDIR += $$quote(../../../Jane/Jane/Build/debug)
message("Copying to Jane Debug Directory.")
}
CONFIG(release, debug|release)
{
DLLDESTDIR += $$quote(../../../Jane/Jane/Build/release)
message("Copying to Jane Release Directory.")
}
FORMS += \
JECMessageText.ui \
JECMessageCombo.ui
由于某种原因,调试或发布DLL被复制到两个目录中,而不只是一个目录中。因此,如果我以发布模式运行,则在Debug目录和发布目录中都将获得发布DLL。
For some reason, the debug or release DLL are copied to both directories instead of just one. So if I run in release mode, I get the release DLL in both the Debug directory and release directory.
我完全感到困惑。有人可以阐明这一点吗?谢谢
I'm totally confused. Could someone shed some light on this? Thanks
推荐答案
左括号应与条件在同一行:
The opening brace should be on the same line as the condition:
CONFIG(debug, debug|release) {
DLLDESTDIR += $$quote(../../../Jane/Jane/Build/debug)
message("Copying to Jane Debug Directory.")
}
CONFIG(release, debug|release) {
DLLDESTDIR += $$quote(../../../Jane/Jane/Build/release)
message("Copying to Jane Release Directory.")
}
或
CONFIG(debug, debug|release) {
DLLDESTDIR += $$quote(../../../Jane/Jane/Build/debug)
message("Copying to Jane Debug Directory.")
} else {
DLLDESTDIR += $$quote(../../../Jane/Jane/Build/release)
message("Copying to Jane Release Directory.")
}
但是都会显示两条消息,因为在运行时都会同时创建文件Makefile.Debug和Makefile.Release。 qmake
(在Windows上,或者在其他操作系统上将debug_and_release添加到CONFIG变量中。)
But both messages will be displayed, because the files Makefile.Debug and Makefile.Release are both created when you run qmake
(on Windows, or if you add debug_and_release to the CONFIG variable on other OSes).
这篇关于Qmake处于发布和调试模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!