在mingw中,qmake copy_dir 总是报错
In mingw,qmake copy_dir is always error
我想复制一些 qml 到我的构建目录。
在 .pro
中,我添加:
copydata.commands = $(COPY_DIR) \"$$PWD/plugins\" \"$$DESTDIR/plugins\"
但是当我构建项目时,copydata
是错误的。
错误信息是:
xcopy /s /q /y /i
"E:/myproject/src/plugins"
"E:/myproject/bin/debug/plugins"
Invalid number of parameters
但是,我把命令复制到cmd,就可以了。
有谁知道哪里错了吗?
Windows 可能会被那些正斜杠搞糊涂了。在所有情况下都尝试使用反斜杠。
我明白了!
谢谢macetw 指路
正确的代码应该是:
copydata.commands = $(COPY_DIR) $$shell_path($$PWD/plugins) $$shell_path($$DESTDIR/plugins)
适用于 Linux 和 Windows Qt 4.8 及更高版本的解决方案:
win32 {
COPY_FROM_PATH=$$shell_path($$PWD/plugins)
COPY_TO_PATH=$$shell_path($$DESTDIR/plugins)
}
else {
COPY_FROM_PATH=$$PWD/plugins
COPY_TO_PATH=$$DESTDIR/plugins
}
copydata.commands = $(COPY_DIR) $$COPY_FROM_PATH $$COPY_TO_PATH
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
有用的链接:
https://forum.qt.io/topic/53817/solved-copy-a-directory-recursively-by-qmake
Where are variables such as $(MKDIR) and $(COPY_DIR) defined?
我想复制一些 qml 到我的构建目录。
在 .pro
中,我添加:
copydata.commands = $(COPY_DIR) \"$$PWD/plugins\" \"$$DESTDIR/plugins\"
但是当我构建项目时,copydata
是错误的。
错误信息是:
xcopy /s /q /y /i "E:/myproject/src/plugins" "E:/myproject/bin/debug/plugins" Invalid number of parameters
但是,我把命令复制到cmd,就可以了。
有谁知道哪里错了吗?
Windows 可能会被那些正斜杠搞糊涂了。在所有情况下都尝试使用反斜杠。
我明白了!
谢谢macetw 指路
正确的代码应该是:
copydata.commands = $(COPY_DIR) $$shell_path($$PWD/plugins) $$shell_path($$DESTDIR/plugins)
适用于 Linux 和 Windows Qt 4.8 及更高版本的解决方案:
win32 {
COPY_FROM_PATH=$$shell_path($$PWD/plugins)
COPY_TO_PATH=$$shell_path($$DESTDIR/plugins)
}
else {
COPY_FROM_PATH=$$PWD/plugins
COPY_TO_PATH=$$DESTDIR/plugins
}
copydata.commands = $(COPY_DIR) $$COPY_FROM_PATH $$COPY_TO_PATH
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
有用的链接:
https://forum.qt.io/topic/53817/solved-copy-a-directory-recursively-by-qmake
Where are variables such as $(MKDIR) and $(COPY_DIR) defined?