SUBDIRS - handling dependencies: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
Line 32: Line 32:
== template: subdirs ==
== template: subdirs ==


To handle this relation automatically qmake has a template type: subdirs ([http://doc.qt.io/qt-5/qmake-variable-reference.html#template template]).
The basic idea of this template type is, to list all projects that belong to a kind of meta project.
A new .pro file is created for that meta project, that simply consists of the qmake system variable [http://doc.qt.io/qt-5/qmake-variable-reference.html#subdirs SUBDIRS]. This variable is filled with the names of the project folders by giving the
relative path to where the meta .pro file lies. In the following text this meta profile is names subdirs.pro.
The name of this meta project for MSVS2010 is solution. The


--[[User:Moellney|Moellney]] ([[User talk:Moellney|talk]]) 22:30, 18 April 2015 (UTC)
--[[User:Moellney|Moellney]] ([[User talk:Moellney|talk]]) 22:30, 18 April 2015 (UTC)

Revision as of 23:06, 18 April 2015

Introduction

It is common for larger software projects to separate its components into different topics. There might be components the are relevant to the GUI of a software, other might be in the topic of handling geometrical processing, others are in the topic of generating a report.

Typically the software components belonging to a topic are combined into a software library (Wikipedia). In Windows these libraries are often found as .lib or .dll files; under Linux there are .a and .so files; under MacOS X they are called .a or .dylib files.

Finally these libraries are linked to an executable application.

The following text uses a small example, consisting of an application: app and two libraries: lib and lib2. The application app uses features of the libraries lib and lib2 while the libraries are in no direct relation. So, to have a running application the toolchain must create the lib.lib and lib2.lib files and finally create the app.exe by linking the lib.lib and lib2.lib to the object files of the app components. (The following Text uses the Windows file name notations of the objects)

When the software project is in an early design and implementation phase, the libraries might change as often as the application using the libraries. In the Qt domain, each of the three topics: lib, lib2 and app will be handled bye one project each. Typically there will be three folders: lib, lib2 and app, each containing a specific .pro file, describing how to handle each project (which source files, compile parameters, ...). The profiles typically will be named after the folders they live in: lib.pro, lib2.pro and app.pro. For this example all three projects will live in one folder: src.

On the file system this can be seen as following hierarchy:

 /src
 |--- app
 |    |--- app.pro
 |    `--- ... (source files of app)
 |--- lib
 |    |--- lib.pro
 |    `--- ... (source files of lib)
 `--- lib2
      |--- lib2.pro
      `--- ... (source files of lib2)
 

Each of this projects could for example be edited separately in three Microsoft Visual Studio 2010 IDEs (MSVS2010) or handled as three separate projects in one QtCreator. But this handling of the projects would mean to compile each by hand separately. It gets tedious when taking into account the dependencies between the three projects: the libs must be compiled before the app can be created!

template: subdirs

To handle this relation automatically qmake has a template type: subdirs (template).

The basic idea of this template type is, to list all projects that belong to a kind of meta project. A new .pro file is created for that meta project, that simply consists of the qmake system variable SUBDIRS. This variable is filled with the names of the project folders by giving the relative path to where the meta .pro file lies. In the following text this meta profile is names subdirs.pro.


The name of this meta project for MSVS2010 is solution. The

--Moellney (talk) 22:30, 18 April 2015 (UTC)