如何使用 qmake 递归复制文件

发布于 2024-11-07 04:03:51 字数 544 浏览 0 评论 0原文

在我的源代码树中,我有很多资源,我想使用 make install 将它们复制到我定义的目标路径。由于资源树有很多很多子目录,我希望 qmake 递归地查找所有文件。

我尝试过:

   resources.path = /target/path
   resources.files += `find /path/to/resources`
   INSTALLS += resources

和:

    resources.path = /target/path
    resources.files += /path/to/resources/*
    resources.files += /path/to/resources/*/*
    resources.files += /path/to/resources/*/*/*
    resources.files += /path/to/resources/*/*/*/*
    INSTALLS += resources

两者都没有达到我希望的结果。

In my source tree I have a bunch of resources, I want to copy them with make install to my defined target path. Since the resource tree has many, many subdirectories, I want qmake to find all files recursively.

I tried:

   resources.path = /target/path
   resources.files += `find /path/to/resources`
   INSTALLS += resources

and:

    resources.path = /target/path
    resources.files += /path/to/resources/*
    resources.files += /path/to/resources/*/*
    resources.files += /path/to/resources/*/*/*
    resources.files += /path/to/resources/*/*/*/*
    INSTALLS += resources

Both don't have the result I was hoping for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晚风撩人 2024-11-14 04:03:51

我是这样做的:

res.path = $OUT_PWD/targetfolder
res.files = sourcefolder

INSTALLS += res

这会将 "无论此 qmake 脚本在哪里"/sourcefolder 复制到 buildfolder/"构建目录上的相同子文件夹"/targetfolder

这样你就可以了targetfolder/sourcefolder/"所有其他子文件夹和文件..."

示例:

#(My .pro file's dir) $PWD = /mysources/
#(My Build dir)       $OUT_PWD = /project_build/


extras.path = $OUT_PWD
extras.files += extras
src.path = $OUT_PWD
src.files += src

INSTALLS += extras src

/mysources/extras 复制到 /project_build/extras/mysources/src/project_build/src

I have done it like this:

res.path = $OUT_PWD/targetfolder
res.files = sourcefolder

INSTALLS += res

this would copy "wherever this qmake script is"/sourcefolder into buildfolder/"same sub folder on build dir"/targetfolder

so you would have targetfolder/sourcefolder/"all other subfolders and files..."

Example:

#(My .pro file's dir) $PWD = /mysources/
#(My Build dir)       $OUT_PWD = /project_build/


extras.path = $OUT_PWD
extras.files += extras
src.path = $OUT_PWD
src.files += src

INSTALLS += extras src

Would copy /mysources/extras to /project_build/extras and /mysources/src to /project_build/src

寒冷纷飞旳雪 2024-11-14 04:03:51

看起来目录是用“cp -r -f”安装的,所以这可以解决问题:

resources.path = /target/path
resources.files += /path/to/resources/dir1
resources.files += /path/to/resources/dir2
resources.files += /path/to/resources/dir3 
resources.files += /path/to/resources/dirn # and so on...
resources.files += /path/to/resources/*    # don't forget the files in the root
INSTALLS += resources

It appears that directories are installed with 'cp -r -f', so this does the trick:

resources.path = /target/path
resources.files += /path/to/resources/dir1
resources.files += /path/to/resources/dir2
resources.files += /path/to/resources/dir3 
resources.files += /path/to/resources/dirn # and so on...
resources.files += /path/to/resources/*    # don't forget the files in the root
INSTALLS += resources
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文