[Cmake] some starting help wanted :-)

Brad King brad.king at kitware.com
Thu, 29 Apr 2004 15:01:42 -0400


Alexander Neundorf wrote:
>>Alexander Neundorf wrote:  
>>
>>>Hi,   
>>>   
>>>until now I used only some basic functions of cmake, now I want to do   
>>>something more with it, i.e. try to add better support for Qt and KDE.  
> 
> 
>>>   
>>>1) There is a FindQt file, which searches for libqt. Now I'd like to   
>>>improve it this way that I can specify which version of Qt I need at  
>>
>>least   
>>
>>>and whether I need the multithreaded version of Qt or not.   
>>
>>  
>>You could modify the file to look for a QT_REQUIRED_VERSION variable and  
> 
> 
>>  use its contents to check for a particular version.  
> 
>   
> Ok, here is a first try.  
>  
> In CMakeLists.txt you can set 
> SET(QT_MT_REQUIRED TRUE) 
> if you need the multithreaded Qt version. 
>  
> You can also set  
> SET(QT_MIN_VERSION "3.2.0") 
> if you require a minimum version of Qt. 
>  
> It also tries to compile and run a very small Qt app. 
>  
> The version checking wasn't quite easy. In qglobal.h there is a
> QT_VERSION_STR 
> defined. But how should I compare this to the value specified in
> QT_MIN_VERSION ? 
> The only way I found so far was to write the attached file 
> CheckForQtMinVersion.cpp.in, where cmake replaces a placeholder with the
> specified 
> minimum version, and which compares this version with the one from
> qglobal.h. Seems to 
> me quite complicated. I also wanted to do something with awk, but this
> doesn't exist 
> under Win, so I guess I can't use it. 
>  
> I had also some problems with getting TRY_COMPILE and TRY_RUN to work. Is
> there a way 
> to get the used compile command and the error and warning messages ? I
> couldn't find 
> them anywhere. 
>  
> What do you think ? Is it on the right track or am I completely off ? 

Here are a couple comments.

We try to avoid using TRY_COMPILE or TRY_RUN in the FindFOO.cmake 
modules.  To check the version number, you can use the STRING command's 
regular expression capabilities to extract the major/minor/patch 
portions.  Alternatively you can write a new CMake command to implement 
finding Qt so that you get the full power of C++.

-Brad