我正在开发一个应该使用QtCreator和Qt 5.3在
Windows,Linux和OS X上构建的应用程序.我想将文件夹中的所有文件和子文件夹复制到输出文件夹中.我已经将它用于Linux和OS X,但不适用于Windows.这是我的.pro文件的相关部分:
win32 { PWD_WIN = $${PWD} DESTDIR_WIN = $${OUT_PWD} copyfiles.commands = $$quote(cmd /c xcopy /S /I $${PWD_WIN}\copy_to_output $${DESTDIR_WIN}) } macx { copyfiles.commands = cp -r $$PWD/copy_to_output/* $$OUT_PWD } linux { copyfiles.commands = cp -r $$PWD/copy_to_output/* $$OUT_PWD } QMAKE_EXTRA_TARGETS += copyfiles POST_TARGETDEPS += copyfiles
如果你看一下带有消息($${PWD})的$${PWD}变量,你会看到/作为目录分隔符,即使在Windows中也是如此.您必须将其转换为本机目录分隔符:
原文链接:https://www.f2er.com/windows/364541.htmlPWD_WIN = $${PWD} DESTDIR_WIN = $${OUT_PWD} PWD_WIN ~= s,/,\\,g DESTDIR_WIN ~= s,g copyfiles.commands = $$quote(cmd /c xcopy /S /I $${PWD_WIN}\\copy_to_output $${DESTDIR_WIN}) QMAKE_EXTRA_TARGETS += copyfiles POST_TARGETDEPS += copyfiles