0
votes

I wondering if there is such a thing like optional targets or sub project in qmake, the Qt build tool.


Project

In my test example I have a subdirs project which contains another two projects, one shared library and one basic application. The application depends on the library which works great. Additionally I have one additional compiler (invoking lrelease) and one additional target (invoking lupdate), which also works like a charm (the shared library provides them as pri file for multiple projects).

After a complete build in release mode, the Windows deployment tool (namely windeployqt.exe) is called and deploys the target with all required shared libraries and plugins to my deployment directory.

Last component I wish to add is the creation of an installer using the Qt Installer Framework, which in fact should be easily done one the executables are located. Thus I want to create another sub project which contains all the installer stuff and provides the qmake steps to create one. But the project should not be build all the time but only when I want to, preferably over the create menu of Qt Creator.

Question

Is there any way to make a qmake subdirs sub project fully optional, so it will not be built using the default build all?

2

2 Answers

2
votes

You can add a check around it:

enableOptional {
    message(optional enabled)
    SUBDIRS += YourSubDir
}

And call qmake with

qmake CONFIG+=enableOptional yourProject.pro
1
votes

The qmake documentation states that one should use the test function requires(condition) to skip building a whole project. Using this one may add a new build configuration, namely bundle as example, which defines a configuration variable as @Jeffrey pointed out in his answer.

I managed to get it working with the following qmake project definition:

requires(BUNDLE_INSTALLER)

TEMPLATE = aux

QMAKE_POST_LINK = ...

Once you define the variable, over a new build configuration for proper working with Qt Creator (example), the steps listed under QMAKE_POST_LINK are performed. So I may bundle the installer, if I want to.