问题
${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:
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 )
回答2:
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).
来源:https://stackoverflow.com/questions/3505858/qt-libraries-in-cmake