tags:

views:

28

answers:

2

${QT_LIBRARIES} seems to turn out as "" when I do message("${QT_LIBRARIES}") and have a general suspicion that it is no being set properly. In fact it doesnt seem as if any of the attributes are being set properly by find_package(Qt4 REQUIRED). Any ideas?

I have also tried find_package(Qt4 4.6.2 COMPONENTS QtCore QtGui REQUIRED )

and I know that it is finding the individual qt libraries (from cmake-gui).

Thanks in advance!

+1  A: 

You have to specify the actual Qt libraries you need, like this: (quoted from the man page)

find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml REQUIRED )
jpalecek
I've seen that before (and tried it out), but it still doesnt seem to define ${QT_LIBRARIES} =/
Cenoc
@Cenoc: this is strange, it works for me. Probably, you have to look in `/usr/share/cmake/Modules/FindQt4.cmake` (or similar on your system) to see what's happening.
jpalecek
It's the 2.8 version, it seems as if it should be set. Well it works if I link in ${QT_QTCORE_LIBRARY}, ${QT_QTGUI_LIBRARY}, ${QT_OPENGL_LIBRARY} manually, but it would've been nice/cleaner to use ${QT_LIBRARIES}.
Cenoc
A: 

The step I think you are missing is,

include(${QT_USE_FILE})

This will load up the QT_LIBRARIES variable, add the modules you requested to the compiler's include path. If you do not include the use file, then you need to link to Qt core etc individually. Most of this information is in the FindQt4.cmake file that is used when find_package is called (the find modules all document their own behavior).

Marcus D. Hanwell