MantisBT - CMake
View Issue Details
0013985CMakeCMakepublic2013-03-05 11:392013-10-07 10:04
Janne Rönkkö 
Clinton Stimpson 
highmajoralways
closedfixed 
LinuxArchlinux
CMake 2.8.10.2 
CMake 2.8.11CMake 2.8.11 
0013985: FindQt4 fails if Qt5 qmake is called qmake
If Qt4 and Qt5 are installed so that qmake is qmake from Qt5 and qmake4 or qmake-qt4 is from Qt4 the FindQt4 module does not find Qt4 but says it found Qt5.

On Archlinux the qmake is currently from Qt5 and qmake-qt4 is the qmake from Qt4.

The attached patch fixes the issue. I left out some strange find_program code that should not be needed in reasonably configured system.
$ cat ../CMakeLists.txt
cmake_minimum_required( VERSION 2.8 )

project( test )

find_package( Qt4 REQUIRED )
$ cmake ..
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/lib/colorgcc/bin/cc
-- Check for working C compiler: /usr/lib/colorgcc/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/colorgcc/bin/c++
-- Check for working CXX compiler: /usr/lib/colorgcc/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - not found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found
CMake Error at /usr/share/cmake-2.8/Modules/FindQt4.cmake:1216 (message):
  Found unsuitable Qt version "5.0.1" from /usr/bin/qmake, this code requires
  Qt 4.x
Call Stack (most recent call first):
  CMakeLists.txt:5 (find_package)


-- Configuring incomplete, errors occurred!
No tags attached.
patch 0001-Fix-FindQt4-module.patch (5,265) 2013-03-05 11:39
https://public.kitware.com/Bug/file/4666/0001-Fix-FindQt4-module.patch
Issue History
2013-03-05 11:39Janne RönkköNew Issue
2013-03-05 11:39Janne RönkköFile Added: 0001-Fix-FindQt4-module.patch
2013-03-07 02:01Stephen KellyNote Added: 0032526
2013-03-07 08:29Janne RönkköNote Added: 0032529
2013-03-07 14:02Marcus D. HanwellNote Added: 0032532
2013-03-09 07:56Janne RönkköNote Added: 0032558
2013-03-11 12:09Andrea ScarpinoNote Added: 0032578
2013-03-13 13:39Brad KingNote Added: 0032610
2013-03-13 13:39Brad KingAssigned To => Clinton Stimpson
2013-03-13 13:39Brad KingStatusnew => resolved
2013-03-13 13:39Brad KingResolutionopen => fixed
2013-03-13 13:39Brad KingFixed in Version => CMake 2.8.11
2013-03-13 13:39Brad KingTarget Version => CMake 2.8.11
2013-10-07 10:04Robert MaynardNote Added: 0034003
2013-10-07 10:04Robert MaynardStatusresolved => closed

Notes
(0032526)
Stephen Kelly   
2013-03-07 02:01   
See

http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/5098 [^]

and

 http://doc-snapshot.qt-project.org/5.0/qtdoc/cmake-manual.html [^]

and maybe

 http://thread.gmane.org/gmane.comp.lib.qt.releasing/744 [^]

Why is arch not using qtchooser?
(0032529)
Janne Rönkkö   
2013-03-07 08:29   
I'm not Archlinux developer, just a user. I have my own Qt4 application that uses CMake. My CMake files has 'find_package( Qt4 REQUIRED )' which currently fails and thus the bug (and the patch).

I did not figure out how using qtchooser would help in this case. Does it change the qmake binary somehow? Or shouldn't I use find_package( Qt4 )?
(0032532)
Marcus D. Hanwell   
2013-03-07 14:02   
Why not have FindQt4 find executables with the -qt4 extension first? If they are there, they are pretty much guaranteed to be Qt4, and I would ideally like to avoid asking developers if they have qtchooser and/or if the defaults they are using are for Qt4.
(0032558)
Janne Rönkkö   
2013-03-09 07:56   
I agree with Marcus. In fact, I first thought that I would submit patch that would put qmake to the last in the array. Then I thought that it might be reasonable to refactor the search logic a bit to get more robust implementation.
(0032578)
Andrea Scarpino   
2013-03-11 12:09   
Thank you dude. This patch is the right way to fix this issue on every distro and installation.
(0032610)
Brad King   
2013-03-13 13:39   
Patch applied with minor tweaks by Clinton:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=21123416 [^]

plus a typo fix reported one day after this was merged to master:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=161a7937 [^]
(0034003)
Robert Maynard   
2013-10-07 10:04   
Closing resolved issues that have not been updated in more than 4 months.