qmake - 使用 Qt 编译项目后将文件复制到构建目录

标签 qmake

我有一个文件“settings.ini”,它需要位于 Qt 可执行文件旁边。

我可以在 Qt Creator 中为此添加一个自定义构建步骤,该步骤调用如下:

copy %{sourceDir}/settings.ini %{buildDir}/settings.ini

到目前为止效果很好,但我想将它包含在 *.pro 文件中,这样我也可以将它放在我们的 SVN 中。

如何仅使用 qmake/.pro-files 来做到这一点?

最佳答案

复制%{sourceDir}/settings.ini到构建目录没有 需要调用make install采用:

copydata.commands = $(COPY_DIR) $$PWD/settings.ini $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
$$PWD是当前 .pro 的路径文件。如果您的 settings.ini文件与项目文件不在同一目录下,则使用类似 $$PWD/more_dirs_here/settings.ini 的内容

备注 : 我找到了这个解决方案 here .我建议阅读整篇文章,因为它解释了它是如何工作的。

关于qmake - 使用 Qt 编译项目后将文件复制到构建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7795397/

相关文章:

c++ - qmake:如何去除绝对路径的依赖?

c++ - Qt Creator : unit-test: is it possible to have four ways of building a code (debug, 发布、调试|发布和测试)

compiler-errors - Qmake找不到文件仍自动完成显示

Qt-project 作为另一个 Qt-project 的 git-submodule

c++ - 将 Qscintilla 库添加到 Qt Problems

c - Qt Creator 上的预处理器输出

qt - 如何利用生成的 Makefile 中的 INSTALL_ROOT?

Qt - 在带有目录的 .pro-File 中使用星号 (*)

android - 在 Qt for Android 中控制所选的 Android NDK 平台版本

c++ - DEPLOYMENT qmake变量的目的是什么?