Importing a .props file in .vcxproj generated by qmake

1.8k Views Asked by At

With a command

qmake -tp vc -r

I'm generating Visual Studio .sln file and a bunch of .vcxproj files from corresponding Qt .pro file and a bunch of .pri files.

I would like those generated .vcxproj files to import my own .props file. A path to which I can provide to qmake or embed it in those .pro/.pri files.

Is it possible? If so then how?

Since by my research it seems that this can by only done by adding a custom extension (which I would have to write first...) to mkspecs...

1

There are 1 best solutions below

1
On BEST ANSWER

Judging by qmake source code, it's not possible. I've looked into qmake\generators\win32\msbuild_objectmodel.cpp in both Qt4.8.5 and latest Qt5 version, and the only Property Sheets that are added by qmake are Microsoft.Cpp.*.props (of various kinds):

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

I have solved this problem by creating a quick Python script, that does the post-processing on the generated *.vcxproj files:

for l in fileinput.FileInput('Project.vcxproj', inplace=1):
    print l,
    if 'PropertySheets' in l:
        print '    <Import Project="YourPropertySheets.props" />'

Of course, it would be better to patch the qmake with the new functionality, but since there are only three people including you and me that are bothered with this, I believe the hack to be the optimal solution.