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

Stephen Kelly stephen.kelly at kdab.com
Tue Nov 1 10:44:18 EDT 2011


On Friday, October 28, 2011 13:13:20 Stephen Kelly wrote:
> == Summary ==
> 
> I'm considering adding some cmake files to Qt, which would be installed by
> Qt,  and which would make it easier for CMake based projects to depend on
> Qt.
> 
> I'm CC'ing the cmake developers too see what they think of the idea too.

>From the feedback, it seems like this is a welcome idea. So I went ahead and 
implemented it. My work is in the KDAB Qt5 clone on gitorious[1].

[1]https://qt.gitorious.org/+kdab-developers/qt/kdab-developers-
qtbase/commit/e79663d1352e7322839dfdfa2fa36bb30aaf4aac

At the moment it's a bit hacky but it does work on linux and it can be cleaned 
up. At this point I'm looking for some initial feedback on the cmake 
dependency (see below).

I was able to build a library in kdelibs framework branch with code similar 
to:

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}
)

So, as a proof of concept, I think I can call this a sucess.

> 
> == Clarification ==
> 
> To avoid misunderstanding:
> 
> * This proposal is not about porting the Qt build system to CMake.
> * This would not make Qt depend on CMake at all
> * I am proposing to add some plain text files to the Qt repo for
> installation * Those plain text files would need to be generated while
> building Qt (using existing mechanisms, like perl).

In the branch, I do depend on cmake at configure-time to generate the Targets 
files. These are platform specific files that cmake uses to build against 
libraries in debug and release versions.

I would like to add this non-optional configure time dependency on cmake to Qt.

The alternative would be to maintain Targets files for multiple platforms by 
generating those files at maintenance time (ie, running the script to generate 
them, copy the result into place and check it in). 

This maintenance burden is not really justifiable. The CMake dependency is 
already available where Qt is available.

Depending on CMake would also mean that I could use configure_file() and 
file(WRITE ...), which would make the stuff work across platforms already 
(currently it depends on sed being available). So I would be able to clean up 
the branch considerably.

Additionally, it would be easier to create a similar Config.cmake file for Qt 
libraries outside of qtbase.git (such as QtWebKit) as I could simply install 
the Qt5BasicConfig.cmake from qtbase and use it from the other repos.

I would make this dependency on CMake non-optional because it is important to 
be able to use find_package(Qt5) without having to care about whether the 
person who built it had cmake installed at the time. find_package(Qt5)  needs 
to work for each Qt5 build, so the config files need to be all the time.

Let me know if this is acceptable for Qt.

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 --------------
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://public.kitware.com/pipermail/cmake-developers/attachments/20111101/7fbbe46d/attachment.sig>


More information about the cmake-developers mailing list