如何让 qmake 生成“项目依赖项”在 Visual Studio .sln 项目中
我有一个由几个库和一个依赖于它们的应用程序组成的 qmake 版本。使用 subdirs 模板,我可以让 qmake 输出一个 .sln 文件,该文件在 VC2008 中几乎符合我的喜好。尽管我已经以我见过的各种方式指定了目标之间的依赖关系,但最终在 .sln 文件中没有“项目依赖关系”,我必须手动添加这些依赖关系。
到目前为止,我已经尝试过
CONFIG += ordered
正确的排序,但没有成功。
类似地,更神秘的语法:
client.depends = core common
这也不起作用。当我加载 sln 时,没有任何依赖项出现。
I have a qmake build of a few libraries and an app which depends on them. Using the subdirs template I'm able to get qmake to output a .sln file which works almost to my liking in VC2008. Though I've specified the dependencies between the targets in every way I've seen described, I end up with no "project dependencies" in the .sln file, and I have to add these in manually.
So far I've tried
CONFIG += ordered
with correct ordering to no avail.
And similarly the more arcane syntax:
client.depends = core common
Which also doesn't work. No dependencies whatsoever show up when I load the sln.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
qmake 的 MSVC 后端(解决方案生成器)不支持
CONFIG +=ordered
和target.depends =
。早在 2010 年 Qt 4.7 左右,文档就没有提到这一点,但在 Qt 4.8 中,开发人员更新了文档 相应(参见目标部分备注):但他们提供了一种解决方法(在神秘帖子中讨论< /a>),它仍然有效,甚至记录在同一个
基本上,当您的 lib 的目标名称(
yourlib.lib
)时,qmake 将生成依赖项等于最终应用程序的导入库之一(具有LIBS += yourlib.lib
)。(请参阅 qmake 的源代码,其中导入库作为依赖项添加,并且 稍微进一步,它们与项目目标名称进行比较)
这是在解决方案中生成依赖项的最小设置:
有了这些,如果您运行
qmake -r -tp vc
,您将在生成的 .sln 中获得显式依赖项:Both
CONFIG += ordered
andtarget.depends =
are not supported by the qmake's MSVC backend (solution generator). Back in 2010 with Qt 4.7 around, the docs didn't mention that, but in Qt 4.8 the developers have updated the docs accordingly (see the Target section remarks):But they had provided a workaround (which is discussed in that cryptic post), and it's still valid and even documented in the same target section. Too bad I had to rebuild qmake and use a debugger to verify that:
Basically, qmake will generate dependency when your lib's target name (
yourlib.lib
) is equal to the one of the import libraries of the final app (that hasLIBS += yourlib.lib
).(See qmake's source where the import libraries are added as dependencies, and a little further where they're compared with the project target names)
Here is the minimal setup that generates dependencies in the solution:
With those, if you run
qmake -r -tp vc
, you'll get the explicit dependency in the generated .sln:来自旧邮件列表条目:
http://lists.trolltech.com/qt-interest/ 2006-07/thread00238-0.html
看来它试图找出哪些事情依赖于你。您是否能够从 sln 进行构建,而无需手动输入项目依赖项?
From an old mailing list entry:
http://lists.trolltech.com/qt-interest/2006-07/thread00238-0.html
It appears that it tries to figure out which things are dependent for you. Are you able to build from the sln without entering the project dependencies manually?
我不是 makefile 专家,但如果我是你,我会尝试通过编辑 .pro 文件、运行 qmake 然后查看 MAKLEFILE 中自动生成的结果,在 QtCreator 中重新创建该依赖关系。如果您想了解 qmake 的工作原理,请查看 qt 文档。
I am not a wiz in makefiles but if I were you, I would try to recreate that dependency in with QtCreator by editing the .pro file, running qmake then looking at the auto-generated result in the MAKLEFILE. If you want to know how qmake works then look at the qt documentation.