4

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...

Adam Badura
  • 5,069
  • 1
  • 35
  • 70

1 Answers1

1

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.

Vladimir Sinenko
  • 4,629
  • 1
  • 27
  • 39
  • FYI: I ended up crafting custom extensions for MS Build to handle Qt in "native style". They work pretty well and could be further improved in few places but MS Build community support is weak and I don't have that much time myself. But what is missing are some nice item templates which would make it even better. Maybe I will add them at some point as well. – Adam Badura Sep 20 '13 at 08:01