将文件复制到输出目录QT

时间:2018-04-25 20:35:51

标签: qt qt5

我目前正努力将项目的子文件夹复制到out目录。我以为我已经正确设置了所有设置,但我想我错过了一步。当我运行make时,我得到一个“没有规则来制作目标'copyfiles'”消息。

我知道我可以使用特定于操作系统的方法创建一个新的构建步骤,但我希望避免它,因为我想最终构建并运行在不同的操作系统上。

修改 是的,之前已经问过这个问题。然而,这些问题中给出的解决方案对我没有用。他们抛出错误或什么都不做。

CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/release
CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/debug

copytarget.path    = $$DESTDIR/etc
copytarget.files  += $$files(etc/*)

## === os specific dir separator ===
win32 {
    copytarget.files ~= s,/,\\,g
    copytarget.path ~= s,/,\\,g
}

message("found files for copytarget: "$$copytarget.files)
message("found files destination: "$$copytarget.path)

## === copy compiler for makefile ===
DirSep = /
win32: DirSep = \\

for(f,copytarget.files) tmp += $$PWD$$DirSep$${f} ## make absolute paths
copycompiler.input        = tmp

isEmpty(DESTDIR):DESTDIR=.
copycompiler.output       = $$DESTDIR$$DirSep${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
copycompiler.commands     = $(COPY_FILE) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
copycompiler.CONFIG       = no_link no_clean
## other CONFIG options are: depends explicit_dependencies target_predeps

copycompiler.variable_out = QMAKE_DISTCLEAN
QMAKE_EXTRA_COMPILERS += copycompiler

## == makefile copy target ===
copyfiles.recurse_target = compiler_copycompiler_make_all
copyfiles.depends        = $$copyfiles.recurse_target
copyfiles.CONFIG        += recursive

MAKE_EXTRA_TARGETS += copyfiles
POST_TARGETDEPS     += copyfiles ## copy files after source compilation

INSTALLS += copytarget

0 个答案:

没有答案
相关问题