Search code examples
c++visual-studioqmakeqt-vs-addin

How to change qmake output path in QT VS Tools


My project's MSVS settings produce the following file tree:

|- .vs
|- Build-x64 // output dir
   |- Debug  // $(Configuration)
      |- .inter // intermediate files
|- MyApp
   |- x64 // Qt output dir
   ...
   |- source files
-MyApp.sln

I want to output qt intermediate files inside Build-x64 folder like so:

|- .vs
|- Build-x64 // output dir
   |- Debug  // $(Configuration)
      |- .inter // intermediate files
         |- Qt  // Qt output dir
|- MyApp
   |- source files
-MyApp.sln

Solution

  • The Simons' link in comments may actually work, but I have found a better solution here. The solution there supposes to use VS' property manager. Here is an except for changing OutDir and IntDir:

    • In the VS menu, select "View > Property Manager".
    • In the Property Manager window, right-click on the project item and select "Add New Project Property Sheet".
    • In the "Add New Item" dialog, set the property sheet name (e.g. CustomDirs.props) and location (e.g. the project directory).
    • In the Property Manager window, expand the project item, and then expand each configuration sub-item; this will show the list of property sheets applied for each configuration, including the one just added.
    • Right-click the new property sheet and select "Properties"
    • In the "Property Pages" dialog for the new property sheet, you can now make any necessary change to project properties (e.g., set the value of "Output Directory" and "Intermediate Directory").
    • Press "OK" on the "Property Pages" dialog, then right-click on the property sheet and select "Save"
    • Adjust the order of evaluation of property sheets by selecting them in the Property Manager window and moving them up or down in the evaluation chain using the "↑" and "↓" buttons. The order of evaluation proceeds from bottom to top of the list of property sheets; so the first property sheet to be evaluated is "Core Windows Libraries", then "Application", then "Microsoft.Cpp.x64.user", etc. For example, to ensure that Qt/MSBuild definitions use the correct values of IntDir and/or OutDir, the customized property sheet must be placed below the "Qt" property sheet in the evaluation order. Right-click the project and select "Save"

    The Qt's paths can be changed in the corresponding parts of settings in property manger. For example you can change Qt Meta-object Compiler -> moc -> OutputDir to $(IntDir)moc\.

    However this method didn't work for one of my projects, that had been already imported using Qt VS tools. I needed to remove all project' files, setup dirs and only then readd all of the files again.