[CMake] FindQt4.cmake to automatically include QT_USE_FILE?

Rolf Eike Beer eike at sf-mail.de
Tue Jun 7 10:32:45 EDT 2011


> Hi all,
>
> As far as I can tell, all Qt programs built with CMake must include
> QT_USE_FILE after find_package(). So why doesn't FindQt4.cmake simply
> include QT_USE_FILE itself? Is there maybe a use case where
> QT_USE_FILE is *not* wanted?

Besides the points already given here is another example:

CMakeLists.txt:

find_package(Qt4 REQUIRED)
add_subdirectory(a)
add_subdirectory(b)

a/CMakeLists.txt

SET(QT_DONT_USE_QTGUI TRUE)
INCLUDE(${QT_USE_FILE})
...
TARGET_LINK_LIBRARIES(foo ${QT_LIBRARIES})

b/CMakeLists.txt
INCLUDE(${QT_USE_FILE})
...
TARGET_LINK_LIBRARIES(bar ${QT_LIBRARIES})

So bar would get linked against QtGui, but foo not. And this all without
fiddling with all the single Qt libraries and their dependencies.

Eike


More information about the CMake mailing list