我有一个库,我希望它根据我所处的配置(调试或发布)将自身复制到目录。这是我的项目文件。
#-------------------------------------------------
#
# 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。
我完全糊涂了。有人可以对此有所了解吗?感谢
答案 0 :(得分:5)
开口支撑应与条件位于同一行:
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.")
}
但是这两条消息都会显示,因为运行qmake
时会创建Makefile.Debug和Makefile.Release文件(在Windows上,或者如果你将debug_and_release添加到其他操作系统的CONFIG变量上)。< / p>