【问题标题】:Could not find .pro file for sub dir - when subdir contains relative path找不到子目录的 .pro 文件 - 当子目录包含相对路径时
【发布时间】:2015-04-09 10:47:50
【问题描述】:

我有一个带有子目录模板的顶级 .pro 文件

TEMPLATE = subdirs

SUBDIRS += \
    common/tests

common/tests 包含 .pro 文件,但 qmake 找不到:

Could not find .pro file for sub dir "common/tests" in "/home/o.antonyan/Documents/mt3/main/src/common/tests"

但它就在那里:

ls /home/o.antonyan/Documents/mt3/main/src/common/tests
api             interfaces            Makefile          tests_common.pro.user  ui
dataformat.cpp  local_enviroment.cpp  tests_common.pro  types

如果我将此 pro 文件移动到父目录并修改顶级 qmake SUBDIRS += common 那么它可以工作。只有当子目录包含超过 1 级深度的相对路径时才会出现问题。

QMake 3.0 版在 GNU/Linux x86 上使用 Qt 5.4.1 版,Qt 从源代码编译

【问题讨论】:

    标签: qt qt5 qmake


    【解决方案1】:

    来自docs

    建议每个子目录中的项目文件与子目录本身具有相同的基本名称,因为这样可以省略文件名。例如,如果子目录名为 myapp,则该目录中的项目文件应名为 myapp.pro。

    尝试将tests_common.pro 重命名为tests.pro

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,并为顶级 .pro 文件找到了这个解决方案:

      TEMPLATE = subdirs
      
      tests_common.file = tests/tests_common.pro
      
      SUBDIRS += tests_common
      

      但现在我更喜欢 svlasov 的答案。

      【讨论】:

      • 这里还需要提一下app.subdir = src/appapp.file = src/app.pro是互斥的:需要一个OR另一个,不能一起用。
      猜你喜欢
      • 2021-04-13
      • 1970-01-01
      • 2016-06-16
      • 1970-01-01
      • 2012-06-13
      • 2016-01-17
      • 2015-06-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多