[SOLVED] Question on subdirs project template



  • This is something I have found to be almost undocumented in the qt docs. Sure, they explain what the qmake SUBDIRS variable does and how to use TEMPLATE = subdirs and CONFIG += ordered, which is fine, but not more useful than any simple variable explanation.
    My questions are:

    • which qmake variables are important for the main .pro file?
    • do variables from the main .pro file propagate through to the subprojects' .pro files?
      ** are any of those variables overridden by default in subprojects' .pro files ?
      ** are headers/source files included in each subproject if you include them in the main .pro file?
    • do subprojects create sub-directories in the project output directory? (e.g. MyProject/subproject1, MyProject/subproject2)
      ** is the DESTDIR variable referencing the main output directory ( MyProject/ ) or a subdirectory ( MyProject/subproject1 )?
    • upon creation of a new subdirs project, Qt Creator generates this code in every subproject .pro file:
      @include(deployment.pri)
      qtcAddDeployment()@
      ** Does this code need to placed on the first line of the .pro file, or after certain variables (for example, after TEMPLATE = app )? Or can it be placed anywhere in the .pro file?

    For now these are the most important questions I can think of. I hope you can help me, and thank you for any answers :)



  • which qmake variables are important for the main .pro file?
    Depends on a project. For example you can find most important variables for a widgets project if you create a Widgets project using qtcreator wizard.

    do variables from the main .pro file propagate through to the subprojects’ .pro files?
    No. All .pro files are independent even if they are specified in SUBDIR .pro file.
    If you have some common block you can put it into .pri file and include that file into each .pro file.

    are any of those variables overridden by default in subprojects’ .pro files ?
    No.

    are headers/source files included in each subproject if you include them in the main .pro file?
    No.

    do subprojects create sub-directories in the project output directory? (e.g. MyProject/subproject1, MyProject/subproject2)
    Yes.

    is the DESTDIR variable referencing the main output directory ( MyProject/ ) or a subdirectory ( MyProject/subproject1 )?
    It is a subdirectory. You can redefine it if you need all target files in the same directory.



  • Hmm... seems quite a waste of purpose having a subprojects template just for having all sub-projects grouped together... I would have found it very useful if I could use the main .pro file to define some general includes, variables...

    well anyway, thank you very much for answering, andreyc :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.