[Interest] Detecting Qt version in cmake

Stephen Kelly steveire at gmail.com
Thu Sep 5 12:04:32 CEST 2013


Joseph W. Joshua wrote:

> Hi all,
> 
> When using cmake, how can one detect whether the Qt version in use is
> greater that Qt4? In qmake, for example, I can determine whether the Qt
> version is greater than Qt4 by using :
> 
> greaterThan(QT_MAJOR_VERSION, 4)xxx
> 
> Anyone know how to do this in cmake?

if(QT_VERSION_MAJOR EQUAL 4)
  # Qt4 code
endif()

Note though that it is possible to have both Qt 4 and Qt 5 in use in the 
same project:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Qt4And5Automoc/CMakeLists.txt;h=0cc80fe73ff1d40433d0980358d3851a9a5065c8;hb=HEAD

Thanks,

Steve.






More information about the Interest mailing list