Problem with cmake 2.4.x and FindQt4 from kdelibs

Alexander Neundorf neundorf at kde.org
Sun Jul 6 10:48:46 CEST 2008


On Thursday 03 July 2008, Tobias Hunger wrote:
> Hello there!
>
> I am trying to build a Qt-only D-Bus application using the FindQt4.cmake
> package found in kdelibs/cmake/modules. That documents a QT_USE_QTDBUS

This means you copied FindQt4.cmake from kdelibs into your project ?

> variable that can be set. So I came up with the following code in my
> CMakeLists.txt:
>
> FIND_PACKAGE(Qt4 REQUIRED)
>
> [...]
>
> SET(QT_USE_QTDBUS ON)
> SET(QT_DONT_USE_QTGUI ON)
> INCLUDE(${QT_USE_FILE})
>
> [...]
>
> TARGET_LINK_LIBRARIES( [...] ${QT_LIBRARIES} [...])
>
> and assumed that my target would get linked against the Qt DBus library.
> Unfortunately that is only true for cmake 2.6 but not for cmake 2.4.x.
>
> After doing some research I found the culprit: FindQt4.cmake defines
> QT_USE_FILE as follows:
>
> SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)

Three options:
-that code could be changed so that UseQt4.cmake from the same dir as the 
current FindQt4.cmake is used
-also add a copy if UseQt4.cmake to your project and modify it as needed
OR
-don't use UseQt4.cmake at all and just list the include dirs and libs as you 
need them (I would suggest this option)

> So I end up including UseQt4.cmake as shipped by CMake. Unfortunately the
> version shipped with cmake 2.4.x is not aware of Qt DBus and thus never
> adds the required flags to QT_LIBRARIES.
>
> So how should I work around this problem? I am requiring cmake version
> 2.6.0 for now (my code is not part of a "normal" kde build, so that should

If it is not part of a "normal" kde build, in which way is it part of a kde 
build ?

Alex


More information about the Kde-buildsystem mailing list