visual-studio - 在 qmake 生成的 .vcxproj 中导入 .props 文件

标签 visual-studio qt qmake vsprops

用命令

qmake -tp vc -r

我正在生成 Visual Studio .sln文件和一堆 .vcxproj来自相应 Qt 的文件 .pro文件和一堆 .pri文件。

我想要那些生成的 .vcxproj导入我自己的文件 .props文件。我可以提供给 qmake 的路径或将其嵌入那些 .pro/.pri文件。

是否可以?如果是,那么如何?

因为根据我的研究,这似乎只能通过向 mkspecs 添加一个自定义扩展(我必须先写...)来完成。 ...

最佳答案

从 qmake 源代码来看,这是不可能的。我查看了 qmake\generators\win32\msbuild_objectmodel.cpp在 Qt4.8.5 和 latest Qt5 version 中, 并且 qmake 添加的唯一属性表是 Microsoft.Cpp.*.props (各种):

xml << tag("Import")
    << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props")
    << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')")
   << closetag()
   << closetag();

我通过创建一个快速的 Python 脚本解决了这个问题,该脚本对生成的 *.vcxproj 文件进行后处理:
for l in fileinput.FileInput('Project.vcxproj', inplace=1):
    print l,
    if 'PropertySheets' in l:
        print '    <Import Project="YourPropertySheets.props" />'

当然,用新功能修补qmake会更好,但是由于只有你和我在内只有三个人对此感到困扰,因此我相信hack是最佳解决方案。

关于visual-studio - 在 qmake 生成的 .vcxproj 中导入 .props 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13860785/

相关文章:

visual-studio - Team Foundation Build 如何选择使用哪个版本的 Visual Studio 进行构建?

c++ - QThread with slots and signals 似乎没有创建新线程

c++ - qmake 不调用 uic

c++ - QMAKE_EXTRA_COMPILERS - 头文件之间的依赖性问题

C#:DataGridView 仅显示一行

c++ - 在 Visual C++ 中读取 WMI 中的 uint 数组属性

visual-studio - vcproj/vsprops 的可选环境变量

c++ - C++的简单多线程混淆

c++ - Qt5.2可以找到mysql驱动但是加载不出来

opencl - 使用 QT5 编译 QtOpenCL