QT PRI文件中的文件路径通过函数

发布于 2025-02-05 01:36:28 字数 822 浏览 5 评论 0原文

我正在.pri文件中创建一个函数,该函数将包含在一个.pro文件中,目的是能够执行:

template(subdirs)
addMyProject(libA)
addMyProject(libB)
addMyProject(libC)

而不是

template(subdirs)
SUBDIRS += libA
libA.path = source/
SUBDIRS += libB
libB.path = source/
SUBDIRS += libC
libC.path = source/

如果我想使用依赖关系关键字,

同一问题。我当前的实现是以下一个:

defineTest(addMyProject) {

  library_name = $$1

  SUBDIRS += $$library_name
  export(SUBDIRS)

  {$$library_name}.file = {$$library_name}/source/{$$library_name}.pro
  QMAKE_EXTRA_TARGETS += {$$library_name}
  export(QMAKE_EXTRA_TARGETS)
}

子段部分还可以。我试图以不同的方式使其适用于.file部分,但我仍然没有找到解决方案。

有提示吗?

[编辑]

每个库都包含不同的子项目,目标是让QT创建者仅查看其中一个(路径源/LibraryName.pro的一个)。 问题在于所有库都正确显示,但也是所有其他子项目。基本上,只有subdirs变量才能识别,但不识别.file关键字)

I am creating a function in a .pri file that will be included in a .pro file with the intent of being able to do:

template(subdirs)
addMyProject(libA)
addMyProject(libB)
addMyProject(libC)

instead of

template(subdirs)
SUBDIRS += libA
libA.path = source/
SUBDIRS += libB
libB.path = source/
SUBDIRS += libC
libC.path = source/

Same problem if I want to use the depend keyword.

My current implementation is the following one:

defineTest(addMyProject) {

  library_name = $1

  SUBDIRS += $library_name
  export(SUBDIRS)

  {$library_name}.file = {$library_name}/source/{$library_name}.pro
  QMAKE_EXTRA_TARGETS += {$library_name}
  export(QMAKE_EXTRA_TARGETS)
}

The SUBDIRS part is ok. I have tried to make it work for the .file part in different ways, but still I have not found a solution.

Any hints?

[EDIT]

Each library contains different sub-projects, and the goal is to let Qt creator see only one of them (the one at the path source/libraryname.pro).
The issue is that all the libraries are correctly displayed, but also all the other sub-projects. Basically, only the SUBDIRS variable is recognised, but not the .file keyword)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文