[Qt-interest] Lots of problems with cmake.

Clinton Stimpson clinton at elemtech.com
Fri Jun 12 22:49:14 CEST 2009


Andreas Pakulat wrote:
> On 12.06.09 10:32:02, Clinton Stimpson wrote:
>   
>>>  
>>>   
>>>       
>>>> # what on earth does this do?
>>>>     
>>>>         
>>> No idea, but its not needed to use Qt.
>>>       
>> You're saying this is not needed?
>> include(${QT_USE_FILE})
>>     
>
> No its not needed, all thats needed is FindQt4.cmake (well technically
> speaking not even that, but then you end up either re-inventing that module
> or hardcoding paths)
>  
>   
>> That's why there's so many different examples on the web.
>> Some use it, some don't.  Those who don't have more complex 
>> CMakeLists.txt files.
>>     
>
> Not necessarily, especially when you only use the standard modules
> (QtCore/QtGui) it doesn't make a lot of sense to use the use-module as
> well. I know the use-module hides some of the details of checking wether a
> particular Qt part is installed (like QtXml, QtWebKit or QtUiTools), but at
> the same time that also means your project might get harder to read.
> In particular if FindQt4+UseQt4 are put into the top-level CMakeLists, but
> the actual targets are distributed. Now when you read:
>
> target_link_library(foo ${QT_LIBRARIES})
>
> its not clear anymore which exact Qt libs are linked to. Not to mention
> that a target might link to unecessary libs this way.
>   
Then take your
 include(${QT_USE_FILE})
out of the top level and do it once for each target if each target uses 
different Qt modules.
>   
>> Since Qt requires a complex build environment (beyond include 
>> directories and libraries to link with), the UseQt4.cmake file can be 
>> used to make it easier.
>>     
>
> No it cannot. The Qt use file doesn't help with anything but include dirs
> and libs as far as I know and can see from this example.
There's also -D QT_NO_DEBUG, -D QT_DEBUG, Mac framework path, -D flags 
for each Qt module.
I don't know why Qt can't use the standard NDEBUG and _DEBUG, and why 
they need the -D flags for some modules.
I prefer it be as simple as including a header and linking a library.
But anyway, its the same stuff for every Qt project, so I prefer a 
simple include(${QT_USE_FILE})
You can get away without those compile flags sometimes.  Sometimes 
depending on your platform.

>  In particular it
> doesn't help with the ugly "having to run a macro to generate moc's from
> headers and cpp's" or the not less ugly "having to run a macro to generate
> code from .ui files". Thats the "complex" things about Qt in the build env,
> both of which are minor annoyances, but nothing really complex IMHO.
>   

Clint



More information about the Qt-interest-old mailing list