Qt Creator: set dependencies between subprojects

In case your project is divided in some subprojects like, the typical case, a main app plus a library you have to be sure, when you make some change into the library, also the main app is automatically recompiled for "integrate" the new changes of the library. This operation can be done by set a dependency between the library and the app.



Googling around for find a solution to this problem someone suggest to use the following QMake options:

CONFIG += ordered

Official documentation here about this option say:

When using the subdirs template, this option specifies that the directories listed should be processed in the order in which they are given.

Is very easy to understand how to use this solution for our purpose. The main app have to be put as final subproject at the end of the subprojects list and this will have the consequence each other subprojects, like a library, will be compiled before. This will ensure any changes will be automatically compiled before the main app. This solution can work but, basically, is only a workaround. Fortunately QMake have a native solution for create dependencies between subproject and the syntax is very easy as follow:

TEMPLATE = subdirs

SUBDIRS += \
MainAppProject \
LibraryProject1 \
LibraryProject2

MainAppProject.depends = LibraryProject1 LibraryProject2

You can find a real example of use in this example QT Creator project here. I think there is no need of detailed explanations. Use the name of your main project with the suffix .depends and assign the list of other projects connected to it. As expected every time you make some changes in the connected subprojects (LibraryProject1 and LibraryProject2 in this example) the MainAppProject will be recompiled in consequence.

Comments

Popular posts from this blog

Access GPIO from Linux user space

Android: adb push and read-only file system error

Tree in SQL database: The Nested Set Model