为了补充这一点(有点晚了!),可以QMAKE_POST_LINK
在构建完成后使用复制文件。例子:
defineReplace(formatpath) {
path = $$1
win32 {
return(\"$$replace(path, "/", "\\")\")
} else:unix {
return($$replace(path, " ", "\\ "))
} else {
error("Unknown platform in formatpath!")
}
}
win32:COPY_CMD = copy
unix:COPY_CMD = cp -P
macx:COPY_CMD = cp -R
win32:CMD_SEP = $$escape_expand(\n\t)
unix:CMD_SEP = ";"
win32:LIB_EXT = dll
unix:LIB_EXT = so*
macx:LIB_EXT = dylib
# Put here the directory of your library's build dir, relative to the current directory
# A path is given for example...
MYLIB_BUILD_DIR = $$_PRO_FILE_PWD_/../lib/bin
QMAKE_POST_LINK += $$COPY_CMD $$formatpath($$MYLIB_BUILD_DIR/*.$$LIB_EXT) $$formatpath($$OUT_PWD/$$DESTDIR) $$CMD_SEP