Bug 16520 - cmake doesn't detect qmake for Qt4
Summary: cmake doesn't detect qmake for Qt4
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: i586 Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Nicolas Lécureuil
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-02 01:24 CEST by Piotr Mierzwinski
Modified: 2019-04-09 10:05 CEST (History)
2 users (show)

See Also:
Source RPM: libqt4-devel-4.8.7-3.mga6.i586.rpm
CVE:
Status comment:


Attachments

Description Piotr Mierzwinski 2015-08-02 01:24:08 CEST
Description of problem:
Command cmake is not able to detect Qt4, and more specifically qmake related with Qt4. It looks like cmake is looking for such command: "qmake-qt4" in "/usr/bin" directory. Above symbolic link should point out to "/usr/lib/qt4/bin/qmake".
I think this symbolic link should be created by above mentioned rpm package (libqt4-devel).

Version-Release number of selected component (if applicable):
libqt4-devel-4.8.7-3

How reproducible:
Run cmake for any Qt4 project based on cmake. I've tested with git://git.qtcmd.org/qtcmd2.git

Steps to Reproduce:
1. git clone git://git.qtcmd.org/qtcmd2.git
2. cd qtcmd2
3. rebuild.sh  (inside is calling cmake)

In result is showing following error:
CMake Error at /usr/share/cmake/Modules/FindQt4.cmake:1326 (message):
  Found unsuitable Qt version "5.5.0" from /usr/bin/qmake, this code requires
  Qt 4.x
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)

When I create symbolic link:
"/usr/bin/qmake-qt4" pointing to "/usr/lib/qt4/bin/qmake"
then I get such message:
-- Found Qt4: /usr/bin/qmake-qt4 (found version "4.8.7") 
and build will start without any errors.


Reproducible: 

Steps to Reproduce:
Rémi Verschelde 2015-08-02 02:03:29 CEST

CC: (none) => lmenut
Assignee: bugsquad => mageia

Comment 1 Nicolas Lécureuil 2015-08-02 10:28:14 CEST
as done on our macro %cmake_qt4 you have to do :

  QTDIR="/usr/lib/qt4" ; export QTDIR ; 
  PATH="/usr/lib/qt4/bin:$PATH" ; export PATH ; 

first as we don't have the link in /usr/bin/ .

Status: NEW => RESOLVED
Resolution: (none) => INVALID

Comment 2 Rémi Verschelde 2015-08-02 11:15:50 CEST
What about adding the qmake-qt4 and qmake-qt5 symlinks though? I agree they are not needed for RPM packaging, but for all end users who try to package Qt applications themselves, it's really annoying to have to run /usr/lib64/qt4/bin/qmake manually to prevent the $PATH from using Qt5's qmake.
Comment 3 Nicolas Lécureuil 2015-08-02 12:47:44 CEST
i won't for qt4 but i can take a look for qt5.
Comment 4 Nicolas Lécureuil 2015-08-02 12:48:22 CEST
forget my previous comment as this is not needed for qt5.
Comment 5 Piotr Mierzwinski 2015-08-03 01:43:19 CEST
@Nicolas Lécureuil  at #1
Sorry, I don't get you :/

> first as we don't have the link in /usr/bin/ .
Yes you have. I didn't create it by myself (I mean link to qmake). Example:

$ cd /usr/bin
$ ls -l | grep qmake
lrwxrwxrwx   1 root root          23 lip 20 11:35 qmake -> /etc/alternatives/qmake*


And about macro:
Please take a look to FindQt4.cmake (up-to date package: cmake-3.3.0-1.mga6):
Quote from: /usr/share/cmake/Modules/FindQt4.cmake:525
  set(_QT4_QMAKE_NAMES qmake qmake4 qmake-qt4 qmake-mac)
  _qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION)

It's clear that cmake will look for "qmake-qt4", which is missing in "/usr/bin"

In my project I use following macro to find Qt4: "find_package(Qt4 REQUIRED phonon)" what works very well in Mageia 5 (in other distributions).

Your recipe doesn't work at all. Above environment variable I had exported in moment when I writing first post, sorry for I didn't put it before. Simply test below:

$ cd /usr/bin
$ mv qmake-qt4 qmake-qt4.bak
$ echo $QTDIR
/usr/lib/qt4
$ echo $PATH
/usr/lib/qt4/bin:/usr/bin:/usr/share/colorgcc:/bin:/usr/bin:/usr/local/bin:/usr/local/games:/usr/games:/usr/lib/qt5/bin:/home/piotr/bin
$
$ ls -l /usr/lib/qt4/bin | grep qmake
-rwxr-xr-x 1 root root 3424236 lip 25 01:47 qmake*
$
$ cd /home/piotr/Projects/qtcmd2
$ rm -rf build; mkdir build; cd build
$ cmake ../
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/cmake/Modules/FindQt4.cmake:1326 (message):
  Found unsuitable Qt version "5.5.0" from /usr/bin/qmake, this code requires
  Qt 4.x
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!


Are able to explain why cmake not looking for qmake in first from PATH path?
I'm not expert how cmake works, that's why I've created qmake-qt4 symbolic link in /usr/bin, what is looked for in "FindQt4.cmake".


I'm not sure what is the problem in creating one more symbolic link (in Qt4 or Qt5 package) to make life easier for people who are creating application with Qt4?
Please note that not everybody (programmers) are using Qt5. I think still there is a lot of applications developing in Qt4. I suppose in other distributions (for example OpenSuse) such link exists. Is there any particular reason that's why you don't want to add it? As you can see above, settin path to qmake from Qt4 as first in PATH doesn't work.

Some workaround in this situation is setting qmake path in main CMakeLists.txt file. Like this: set(QT_QMAKE_EXECUTABLE /usr/lib/qt4/bin/qmake)
The issue here is that I'm not sure if in other distribution this location for qmake will be correct. The most likely for all using Plasma 5 will be fine, but for other NOT (Mageia 5, OpenSuse 13.2 and others). So it made that source code is not portable.
Second workaround is create synbolic link yourself.
Anyway workaround is always bad solution.

Status: RESOLVED => REOPENED
Resolution: INVALID => (none)

Comment 6 Nicolas Lécureuil 2015-08-09 01:06:59 CEST
Please test next qt4.
Comment 7 Piotr Mierzwinski 2015-08-09 20:56:30 CEST
After update all is fine :).
From cmake I get followin message:
-- Found Qt4: /usr/bin/qmake-qt4 (found version "4.8.7")

Big thanks Nicolas.
Comment 8 Piotr Mierzwinski 2015-08-09 20:58:23 CEST
Fixed.

Status: REOPENED => RESOLVED
Resolution: (none) => FIXED

Comment 9 Nicolas Lécureuil 2015-08-09 21:19:10 CEST
you're welcome :)
Sunny yadav 2019-04-08 19:06:31 CEST

CC: (none) => arkr17997


Note You need to log in before you can comment on or make changes to this bug.