Qt component defines

Pau Garcia i Quiles pgquiles at elpauer.org
Thu Aug 27 00:48:54 CEST 2009


On Thu, Aug 27, 2009 at 12:30 AM, Clinton Stimpson<clinton at elemtech.com> wrote:
> Pau Garcia i Quiles wrote:
>>
>> On Wed, Aug 26, 2009 at 11:25 PM, Christoph Feck<christoph at maxiom.de>
>> wrote:
>>
>>>
>>> Hi,
>>>
>>> When using Qt qmake, you define the actual Qt components using the "Qt +=
>>> Xml"
>>> etc. flags. In addition to adjusting include and linking options, this
>>> also
>>> adds an "QT_XML_LIB" define.
>>>
>>> The problem is that QtTest headers (from 4.6-stable branch) conditionally
>>> define GUI related classes based on the QT_GUI_LIB define to avoid
>>> linking
>>> with QtGui on pure QtCore tests.
>>>
>>> CMake, however, does not set these defines, and I am wondering if it
>>> should,
>>> or if I should workaround that in the project files that currently fail.
>>>
>>> For example, unless I use "add_definitions(-DQT_GUI_LIB)" I get errors
>>> about
>>> missing symbols when compiling skrooge and kdevelop.
>>>
>>
>> I forwarded the OP mail to Clinto Stimpson, who is the FindQt4.cmake
>> module maintainer. This is his answer:
>>
>> "
>> UseQt4.cmake adds -D flags for each module.
>> Are they not correct?  When I added those -D flags it was based on
>> qmake's behavior.
>>
>> Clint
>> "
>>
>> I guess the problem is in KDE we do not do INCLUDE( ${QT_USE_FILE} )
>> because we do not use the QT_LIBRARIES var. The reason we do not do
>> that is with so many projects being configured in the same CMake pass,
>> QT_LIBRARIES would be useless: it would contain the sum of all the Qt
>> libraries any one project has requested at some time by using SET(
>> QT_USE_QTXXX 1).
>>
>> Maybe we should do INCLUDE( ${QT_USE_FILE} ) but keep on NOT using
>> QT_LIBRARIES ?
>>
>>
>
> Actually, you do a include(${QT_USE_FILE}) for each project, not once for
> all of them.
> Then you have control of which Qt modules to activate for which projects.

I know but take this example:

projectA
   |
   \--- projectB
             |
             \--- projectC

projectA has FIND_PACKAGE( Qt4 COMPONENTS QtCore QtNetwork ) and
INCLUDE( ${QT_USE_FILE} )
projectB has FIND_PACKAGE( Qt4 COMPONENTS QtCore QtGui QtXml QtSql )
and INCLUDE( ${QT_USE_FILE} )
projectC has FIND_PACKAGE( Qt4 COMPONENTS QtCore QtGui QtOpenGL ) and
INCLUDE( ${QT_USE_FILE} )

Due to variable inheritance, in projectC, QT_LIBRARIES is not QtCore
QtGui QtOpenGL QtSql but Qtcore, QtGui, QtNetwork, QtXml, QtSql and
QtOpenGL, therefore the definitions for all those libraries are added
by means of ADD_DEFINITIONS, which is wrong: I don't want the
definitions for QtSql to be present while compiling projectC because
I'm not using QtSql in projectC

(I'm attaching the hierarchy I used as an example, run CMake in it and
you'll see the problem)

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_use_file_inheritance.tar.bz2
Type: application/x-bzip2
Size: 539 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-buildsystem/attachments/20090827/cbb374b7/attachment.bin 


More information about the Kde-buildsystem mailing list