6.9 Using KDE

6.9.1 Variable definitions

Table 6-7. Variables for ports that use KDE

USE_KDELIBS_VER The port uses KDE libraries. It specifies the major version of KDE to use and implies USE_QT_VER of the appropriate version. The only possible value is 3.
USE_KDEBASE_VER The port uses KDE base. It specifies the major version of KDE to use and implies USE_QT_VER of the appropriate version. The only possible value is 3.

6.9.2 Ports that require Qt

Table 6-8. Variables for ports that use Qt

USE_QT_VER The port uses the Qt toolkit. Possible values are 3 and 4; each specify the major version of Qt to use. Appropriate parameters are passed to configure script and make.
QT_PREFIX Set to the path where Qt installed to (read-only variable).
MOC Set to the path of moc (read-only variable). Default set according to USE_QT_VER value.
QTCPPFLAGS Additional compiler flags passed via CONFIGURE_ENV for Qt toolkit. Default set according to USE_QT_VER.
QTCFGLIBS Additional libraries for linking passed via CONFIGURE_ENV for Qt toolkit. Default set according to USE_QT_VER.
QTNONSTANDARD Suppress modification of CONFIGURE_ENV, CONFIGURE_ARGS, and MAKE_ENV.

Table 6-9. Additional variables for ports that use Qt 4.x

QT_COMPONENTS Specify tool and library dependencies for Qt4. See below for details.
UIC Set to the path of uic (read-only variable). Default set according to USE_QT_VER value.
QMAKE Set to the path of qmake (read-only variable). Default set according to USE_QT_VER value.
QMAKESPEC Set to the path of configuration file for qmake (read-only variable). Default set according to USE_QT_VER value.

When USE_QT_VER is set, some useful settings are passed to configure script:

CONFIGURE_ARGS+= --with-qt-includes=${QT_PREFIX}/include \
                 --with-qt-libraries=${QT_PREFIX}/lib \
                 --with-extra-libs=${LOCALBASE}/lib \
                 --with-extra-includes=${LOCALBASE}/include
CONFIGURE_ENV+=  MOC="${MOC}" CPPFLAGS="${CPPFLAGS} ${QTCPPFLAGS}" LIBS="${QTCFGLIBS}" \
                 QTDIR="${QT_PREFIX}" KDEDIR="${KDE_PREFIX}"

If USE_QT_VER is set to 4, the following settings are also deployed:

CONFIGURE_ENV+= UIC="${UIC}" QMAKE="${QMAKE}" QMAKESPEC="${QMAKESPEC}"
MAKE_ENV+=      QMAKESPEC="${QMAKESPEC}"

6.9.3 Component selection (Qt 4.x only)

When USE_QT_VER is set to 4, individual Qt4 tool and library can be specified in the QT_COMPONENTS variable. Most important components are listed below (all components are listed in _QT_COMPONENTS_ALL of /usr/ports/Mk/bsd.kde.mk):

Table 6-10. Available Qt4 library components

Name Description
corelib core library (can be omitted unless the port uses nothing but corelib)
gui graphical user interface library
network network library
opengl OpenGL library
qt3support Qt3 compatibility library
qtestlib unit testing library
sql SQL library
xml XML library

You can determine which libraries the application depends on, by running ldd on the main executable after a successful compilation.

Table 6-11. Available Qt4 tool components

Name Description
moc meta object compiler (you need it for almost every Qt applications)
qmake build utility of the Qt project
rcc resource compiler (if application has *.rc or *.qrc files)
uic user interface compiler (if the application uses GUI)

Table 6-12. Available Qt4 plugin components

Name Description
iconengines SVG icon engine plugin (if the application ships SVG icons)
imageformats imageformat plugins for GIF, JPEG, MNG and SVG (if the application ships image files)

Example 6-2. Selecting Qt4 components

The following fragment is from the port editors/texmaker which uses Qt4 graphical user interface library (it also implies it uses the core library) and building tools:

USE_QT_VER=    4
QT_COMPONENTS= gui moc qmake rcc uic

6.9.4 Additional considerations

If the application does not provide a configure file but a .pro file, you can use the following:

HAS_CONFIGURE= yes

do-configure:
        @cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} \
                ${QMAKE} -unix PREFIX=${PREFIX} texmaker.pro

Note the similarity to the qmake line from the provided BUILD.sh script. Passing CONFIGURE_ENV ensures qmake will see the QMAKESPEC variable, without which it cannot work. qmake generates standard Makefiles, so it is not necessary to write our own build target.

Qt applications often are written to be cross-platform and often X11/Unix isn't the platform they are developed on, which in turn often leads to certain loose ends, like:

Note: At the moment, bsd.kde.mk isn't pre/postmk-safe, which means you cannot use USE_QT_VER and QT_COMPONENTS after including bsd.port.pre.mk. If your port requires this, please depend on the component you need the traditional way for now, for example:

.include <bsd.port.pre.mk>

.if defined(WITH_QT)
BUILD_DEPENDS+= moc4:${PORTSDIR}/devel/qt4-moc
LIB_DEPENDS+=   QtCore:${PORTSDIR}/devel/qt4-corelib
.endif

.include <bsd.port.post.mk>
For questions about the FreeBSD ports system, e-mail <ports@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.