QTCreator使用INSTALLS将文件复制到输出目录

Hor*_*ter 12 qt qmake build qt-creator

我有两个子目录docroot,config在我的Qt项目中.每当我构建/调试项目时,都应将这些目录中的文件复制到构建目录中.

/sf/answers/279384731/开始,可以使用INSTALLS(QtDoc),这似乎比运行复制命令容易得多(例如这里).这里描述类似的方法.

config.path    = $${DESTDIR}/config
config.files   = config/*
docroot.path   = $${DESTDIR}/docroot
docroot.files  = docroot/*
INSTALLS       += config docroot
Run Code Online (Sandbox Code Playgroud)

但是,当我在Qt Creator中运行构建时,没有任何反应.这在这里说,我需要运行make install.每当我构建时,我都能以某种方式从Qt Creator中自动触发/执行此操作.我总是需要最新版本的文件.

编辑:最终我用$$OUT_PWD而不是$$DESTDIR

从洛根原创评论这里 "刚一说明:我用$$OUT_PWD,而不是$$DESTDIR使其工作参考.$$OUT_PWD是程序内置到该文件夹,并且$$PWD是它在该程序正在从-换句话说内置的文件夹.pro文件是."

Bil*_*ill 17

您需要的是自定义构建步骤.

  1. 切换到项目模式:按Ctrl + 5.
  2. Build Steps下的Build Settings选项卡上,单击Add Build Step.
  3. 从菜单中选择" 制作 ".
  4. 安装写入Make参数:文本输入框.

(我检查这些的版本是Qt Creator 2.4.1.)


For*_*gic 6

我在Window 7上使用Shadow Build而且遇到了与你相同的问题.

此外,在设置INSTALLS并运行make install后,我收到以下消息:

"安装"没什么可做的.

原因是你必须自己设置$$ DESTDIR.

在我的情况下,我想复制*.qml文件,这就是我实现它的方式:

# if you are using Shadow build, you need to get the output folder
CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/release
CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/debug

# if you are using normal build (non-shadow) that would have worked as well.
CONFIG(release, debug|release): DESTDIR = release
CONFIG(debug, debug|release): DESTDIR = debug    

QmlFiles.path = $$DESTDIR/Qml
QmlFiles.files += $$files(Qml/*.qml)

INSTALLS += QmlFiles
Run Code Online (Sandbox Code Playgroud)

编辑:

我发现$$OUT_PWD可以用来找到Shadow Build Output路径.所以,我修复了最终接近你正在使用的代码.