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

Thiago Macieira thiago.macieira at intel.com
Wed Nov 2 18:40:23 CET 2011


On Wednesday, 2 de November de 2011 18:12:58 Stephen Kelly wrote:
> > But we agreed that including that file when you have more than one target
> > in your CMakeLists.txt is a bad idea.
> 
> Well, we agreed that the issue exists. There are non-perfect solutions, but
> the -D options have not been missing from CMake even though KDE didn't use
> them.

Two wrongs don't make a right (but three lefts do).

> Ok, so what you really wanted to say is "don't use target_link_libraries
> directly. Use a wrapper macro that does that and the other important and
> necessary things". Is that right?

Yes.

> > Something will need to add the macros :-)
> 
> You mean a FindQt5.cmake would be needed to add macros? Why can't that be
> done in the config files?
> 
> The qt5_add_module macro would be defined in Qt5CoreMacros.cmake, installed
> alongside Qt5CoreConfig.cmake, and Qt5CoreConfig.cmake contains the line:
> 
> include(${CMAKE_CURRENT_LIST_DIR}/Qt5CoreMacros.cmake)
> 
> Similarly, the qt5_add_dbus_interfaces macro would be defined in
> Qt5DBusMacros.cmake installed alongside Qt5DBusConfig.cmake with a similar
> include.

Well, as long as it works, it doesn't matter how it's implemented.

> This then introduces the problem of where does FindQt5.cmake get installed
> from? It would have to be in CMake itself. Seems like an odd thing to do
> just for the purpose of keeping a list out of Qt5Config.cmake. 

That's a good point. But I'd like searching, not listing. Or like the module 
support in qmake: open a file that is supposed to be there. If the file is 
missing, then the module is not installed.

> So I can just change it to this:
> 
> if (NOT Qt5_FIND_COMPONENTS)
>   # By default we look all Qt modules
>   set(Qt5_FIND_COMPONENTS
>       Core
>       Gui
>       Widgets
>       Webkit
>       # TODO: Add the others
>   )
> endif()

How do you list the modules that don't exist yet and don't have a name?

> If the list has to be maintained somewhere, it only makes sense to maintain
> it in Qt.

There is no list.

Well... there is a "Qt 5.x" release, which has a list of components tested and 
released. But I was hoping that the CMake support would work for other addons, 
modules that aren't part of that release.

Then again... those addons have their own version numbers. We'd have to have 
something like pkg-config:

qt5_add_modules(mytarget Gui AddonFoo >= 1.1 AddonBar == 2.0)

Or if you tell me that the "cmake way" is to write:

find_package(Qt5 VERSION 5.1)
find_package(Qt5AddonFoo VERSION 1.1)
find_package(Qt5AddonBar VERSION 2.0)

Then I will defer to you. But then Qt5Config.cmake should really be for qtbase 
only. Qt Quick and QtWebKit versions are already on a different pace and 
number.

I like my solution better.

> > But I don't mind having to declare the *optional* packages, the ones that
> > I
> > will use conditionals on. What I don't want is to have to do the double-
> > booking of the mandatory ones.
> 
> By 'mandatory' and 'optional' you mean QtEssentials vs QtAddons?

No. I mean in the sense from KDE: mandatory packages must be installed or my 
project will not compile; optional packages add extra functionality, but its 
absence does not stop the build.

Qt Essentials are modules that must be present for a platform to call itself a 
Qt 5 platform. However, it's possible to have platforms with only a partial 
set of modules -- it just cannot call itself a Qt 5 platform. Think of small 
embedded devices that don't need QtWebKit or Qt Quick.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20111102/0c57c3d1/attachment.sig>


More information about the Development mailing list