Qt component defines

Clinton Stimpson clinton at elemtech.com
Thu Aug 27 01:04:14 CEST 2009


Pau Garcia i Quiles wrote:
> 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)
>
>   
FindQt4.cmake won't add those defines because it doesn't know which 
modules will be used.
I guess you could either do it manually, or maybe use function() to 
create a new scope for variables and do some work in that scope.

Clint



More information about the Kde-buildsystem mailing list