【问题标题】:How can I use qmake to copy files recursively如何使用 qmake 递归复制文件
【发布时间】:2011-05-11 10:10:39
【问题描述】:

在我的源代码树中,我有一堆资源,我想用 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

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

【问题讨论】:

    标签: qmake


    【解决方案1】:

    我是这样做的:

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

    这会将"wherever this qmake script is"/sourcefolder 复制到buildfolder/"same sub folder on build dir"/targetfolder

    所以你会有targetfolder/sourcefolder/"all other subfolders and files..."

    例子:

    #(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

    【讨论】:

      【解决方案2】:

      目录似乎是用 '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
      

      【讨论】:

      • 您是否尝试过使用替换功能files() 来枚举文件? $$files(/path/to/resources/*, true) 递归返回/path/to/resources 中的所有文件。
      猜你喜欢
      • 2011-10-27
      • 2018-02-07
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多