[Development] Installing Qt5Config.cmake from the Qt repo?

Stephen Kelly stephen.kelly at kdab.com
Tue Nov 1 15:58:10 CET 2011


On Tuesday, November 01, 2011 15:49:27 Thiago Macieira wrote:
> On Tuesday, 1 de November de 2011 15:44:18 Stephen Kelly wrote:
> > find_package(Qt5 REQUIRED Core Gui Widgets)
> > include(${Qt5_USE_FILE})
> > 
> > add_library(itemmodels SHARED ${itemmodels_SRCS})
> > target_link_libraries(itemmodels
> > 
> >     ${Qt5Core_LIBRARY}
> >     ${Qt5Gui_LIBRARY}
> >     ${Qt5Widgets_LIBRARY}
> > 
> > )
> 
> Where's the include_directories call?
> 
> if that's hidden in that ${Qt5_USE_FILE}, can you have different use-files
> per target? For example, a test associated with that library above will
> need to include and link to QtTest.

Yes, the include_directories call is hidden in the use file. The Qt5Use.cmake 
file looks like this:

foreach(_USE_FILE ${Qt5_USE_FILES})
    include(${_USE_FILE})
endforeach()

Qt5_USE_FILES is a variable populated by Qt5Config.cmake. It is a list of use 
files resulting from the call to find_package. That is 

find_package(Qt5 COMPONENTS Core DBus Test)

creates a Qt5_USE_FILES list which contains the use files Qt5CoreUse.cmake, 
Qt5DBusUse.cmake and Qt5TestUse.cmake.

This also means that instead of 

include(${Qt5_USE_FILE})

you can use 

include(${Qt5Core_USE_FILE})
include(${Qt5DBus_USE_FILE})
include(${Qt5Test_USE_FILE})

Also, instead of 

find_package(Qt5 REQUIRED Core Gui Widgets)

you can use:

find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Gui)

It is completely granular. Qt5Config.cmake and Qt5Use.cmake are just simple 
aggregators as discussed.

Thanks,

-- 
Stephen Kelly <stephen at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20111101/eedfe398/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20111101/eedfe398/attachment.sig>


More information about the Development mailing list