我有一个 qmake 构建的几个库和一个依赖于他们的应用程序。使用subdirs模板我能够得到qmake输出一个.sln文件,几乎是我喜欢在VC2008。虽然我已经以我所见过的每种方式指定了目标之间的依赖关系,但我最终在.sln文件中没有项目依赖,我必须手动添加这些依赖。
到目前为止,我尝试了
CONFIG + = ordered正确的顺序无效。
client.depends = core common
这也不工作。 c> $ CONFIG + =
解决方案 qmake的MSVC后端(解决方案生成器)不支持c $ c>和 target.depends = 。回到2010年的Qt 4.7周围,文档没有提到,但在Qt 4.8开发人员更新了文档(见目标部分备注):- .depends 此子项目取决于指定的子项目。仅适用于使用makefile的平台 。
- Visual Studio不支持订购选项。
但他们提供了一个解决方法(在加密帖),它仍然有效,甚至记录在同一个 target 部分。太糟糕了,我不得不重建qmake和使用调试器来验证:
是一个Lib / DLL项目,其中TARGET(使用.lib而不是.dll)在解决方案的另一个项目的链接行上使用(您可以修改与LIBS的链接行)。
b)有一个Exe项目,其中TARGET用于您解决方案中另一个项目的自定义构建步骤。
基本上,当你的lib目标名( yourlib.lib )等于最终应用程序的导入库时,qmake会生成依赖( LIBS + = yourlib.lib )。(请参阅 qmake的源,其中导入库作为依赖关系添加,并且稍后他们与项目目标名称进行比较)
以下是在解决方案中生成依赖关系的最小设置:
solution.pro TEMPLATE = vcsubdirs SUBDIRS = main app app / app.pro LIBS + = main.lib main / main.pro TARGET = main TEMPLATE = vclib如果你运行 qmake -r - tp vc ,您将在生成的.sln中获得显式依赖:
GlobalSection )= postSolution {E634D0EB-B004-3246-AADA-E383A376158F} .0 = {1BD6E999-63E6-36F5-99EE-1A650332198C} EndGlobalSection
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 += orderedwith correct ordering to no avail.
And similarly the more arcane syntax:
client.depends = core commonWhich also doesn't work. No dependencies whatsoever show up when I load the sln.
解决方案Both CONFIG += ordered and target.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):
- .depends This subproject depends on specified subproject. Available only on platforms that use makefiles.
- The ordered option is not supported for Visual Studio.
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:
a) There is a Lib/DLL project of which TARGET (the .lib is used and not the .dll) is used on the link line of another project in your solution (you can modify the link line with LIBS).
b) There is an Exe project of which TARGET is used in a custom build-step of another project in your solution.
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 has LIBS += 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:
solution.pro TEMPLATE = vcsubdirs SUBDIRS = main app app/app.pro LIBS += main.lib main/main.pro TARGET = main TEMPLATE = vclibWith those, if you run qmake -r -tp vc, you'll get the explicit dependency in the generated .sln:
GlobalSection(ProjectDependencies) = postSolution {E634D0EB-B004-3246-AADA-E383A376158F}.0 = {1BD6E999-63E6-36F5-99EE-1A650332198C} EndGlobalSection
更多推荐
如何获取qmake来生成“项目依赖”在Visual Studio .sln项目中
发布评论