Qt Lite: Tailoring your Qt build to your needs

Qt Lite: Tailoring your Qt build to your needs
The Problem: Getting the smallest functional Qt
I
Popular question: How do I minimize my Qt build?
I
Particularly relevant for single-purpose static builds for
embedded systems
I
Different people have different requirements
I
The “essential Qt” is not the same for everybody
Modules
I
Coarse-grained
I
QtCore, QtNetwork, QtQuick, ...
I
Build just the modules you need
I
But what if you need some parts of a module only?
Features
I
Fine-grained
I
Selectively enable/disable parts of the Qt code base
I
For instance: QProcess, QSettings, QRegularExpression, state
machine support...
I
There are ca. 150 features in qtbase at the moment
I
Number will likely increase in the future
Enabling and disabling Qt features
I
Happens at configure time
I
Relevant options: -feature-* and -no-feature-*
I
Opt out of features you don’t need like this:
configure -no-feature-mimetype
-no-feature-openssl
...
I
Graphical tool available as part of Qt for Device Creation
Example
I
Built Qt statically for the i.MX 6 architecture
I
I
First variant used default configure options
Second variant had several dozen features turned off
I
A Qt Quick application showing some animation was built
against both variants
I
The executable built against variant two was 30% smaller
Dealing with Qt features in your projects
I
Tailor your project to the availability of features:
I
In a project file:
qtConfig(openssl):SOURCES += mysslcode.cpp
I
In a source file:
#if QT_CONFIG(openssl)
// SSL-specific code goes here
#endif
I
You can also declare that your code needs a certain feature:
QT_REQUIRE_CONFIG(openssl)