The Ports Collection provides support for Qt 4 and Qt 5
frameworks with
USE_QT,
where xx is
4 or 5.
Set USE_QT
to the list of required Qt components (libraries,
tools, plugins). The Qt 4 and Qt 5 frameworks are quite
similar. The main difference is the set of supported
components.x
The Qt framework exports a number of variables which can be used by ports, some of them listed below:
QT_PREFIX | Set to the path where Qt was installed
(${LOCALBASE}). |
QMAKE | Full path to qmake
binary. |
LRELEASE | Full path to lrelease
utility. |
MOC | Full path to moc. |
RCC | Full path to rcc. |
UIC | Full path to uic. |
QT_INCDIR | Qt include directory. |
QT_LIBDIR | Qt libraries path. |
QT_PLUGINDIR | Qt plugins path. |
When using the Qt framework, these settings are deployed:
CONFIGURE_ARGS+= --with-qt-includes=${QT_INCDIR} \
--with-qt-libraries=${QT_LIBDIR} \
--with-extra-libs=${LOCALBASE}/lib \
--with-extra-includes=${LOCALBASE}/include
CONFIGURE_ENV+= QTDIR="${QT_PREFIX}" QMAKE="${QMAKE}" \
MOC="${MOC}" RCC="${RCC}" UIC="${UIC}" \
QMAKESPEC="${QMAKESPEC}"
PLIST_SUB+= QT_INCDIR=${QT_INCDIR_REL} \
QT_LIBDIR=${QT_LIBDIR_REL} \
QT_PLUGINDIR=${QT_PLUGINDIR_REL}Some configure scripts do not support the arguments above.
To suppress modification ofCONFIGURE_ENV
and CONFIGURE_ARGS, set
QT_NONSTANDARD.
Individual Qt tool and library dependencies must be
specified in
USE_QT.
Every component can be suffixed with
x_build or _run, the
suffix indicating whether the dependency on the component is
at buildtime or runtime. If unsuffixed, the component will be
depended on at both build- and runtime. Usually, library
components are specified unsuffixed, tool components
are mostly specified with the _build suffix
and plugin components are specified with the
_run suffix. The most commonly used
components are listed below (all available components are
listed in _USE_QT_ALL,
_USE_QT4_ONLY, and
_USE_QT5_ONLY in
/usr/ports/Mk/bsd.qt.mk):
| Name | Description |
|---|---|
core | core library (Qt 5 only) |
corelib | core library (Qt 4 only) |
dbus | Qt DBus library |
gui | graphical user interface library |
network | network library |
opengl | Qt OpenGL library |
script | script library |
sql | SQL library |
testlib | unit testing library |
webkit | Qt WebKit library |
xml | Qt XML library |
To determine the libraries an application
depends on, run ldd on the main
executable after a successful compilation.
| Name | Description |
|---|---|
qmake | Makefile generator/build utility |
buildtools | build tools (moc,
rcc), needed for almost
every Qt application (Qt 5 only) |
linguisttools | localization tools: lrelease,
lupdate (Qt 5 only) |
linguist | localization tools: lrelease,
lupdate (Qt 4 only) |
moc | meta object compiler, needed for almost every Qt application at buildtime (Qt 4 only) |
rcc | resource compiler, needed if the application
comes with *.rc or
*.qrc files (Qt 4 only) |
uic | user interface compiler, needed if the
application comes with *.ui
files, in practice, every Qt
application with a GUI (Qt 4 only) |
| Name | Description |
|---|---|
iconengines | SVG icon engine plugin, needed if the application ships SVG icons (Qt 4 only) |
imageformats | plugins for TGA, TIFF, and MNG image formats |
In this example, the ported application uses the Qt 4
graphical user interface library, the Qt 4 core library,
all of the Qt 4 code generation tools and Qt 4's Makefile
generator. Since the gui library
implies a dependency on the core library,
corelib does not need to be specified.
The Qt 4 code generation tools moc,
uic and rcc, as well
as the Makefile generator qmake are
only needed at buildtime, thus they are specified with the
_build suffix:
USE_QT4= gui moc_build qmake_build rcc_build uic_build
If the application provides a
qmake project file
(*.pro), define
USES= qmake along with
USE_QT. Note
that xUSES= qmake already implies a build
dependency on qmake, therefore the qmake component can be
omitted from
USE_QT.
Similar to CMake,
qmake supports out-of-source
builds, which can be enabled by specifying the
xoutsource argument (see USES= qmake
example).
qmake| Variable | Means |
|---|---|
QMAKE_ARGS | Port specific qmake
flags to be passed to the qmake
binary. |
QMAKE_ENV | Environment variables to be set for the
qmake binary. The default is
${CONFIGURE_ENV}. |
QMAKE_SOURCE_PATH | Path to qmake project files
(.pro). The default is
${WRKSRC} if an
out-of-source build is requested, empty
otherwise. |
USES= qmake ExampleThis snippet demonstrates the use of qmake for a Qt 4 port:
USES= qmake:outsource USE_QT4= moc_build
For a Qt 5 port:
USES= qmake:outsource USE_QT5= buildtools_build
Qt applications are often written to be cross-platform and often X11/Unix is not the platform they are developed on, which in turn leads to certain loose ends, like:
Missing additional include
paths. Many applications come with
system tray icon support, but neglect to look for
includes and/or libraries in the X11 directories. To add
directories to qmake's
include and library search paths via the command
line, use:
QMAKE_ARGS+= INCLUDEPATH+=${LOCALBASE}/include \
LIBS+=-L${LOCALBASE}/libBogus installation paths.
Sometimes data such as icons or .desktop files are by
default installed into directories which are not scanned
by XDG-compatible applications.
editors/texmaker is
an example for this - look at
patch-texmaker.pro in the
files directory of that port for a
template on how to remedy this directly in the
qmake project file.
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.