[cmake-developers] [CMake 0011779]: FindQt4 fails because I re-organised my Qt folder

Mantis Bug Tracker mantis at public.kitware.com
Mon Jan 31 16:38:49 EST 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=11779 
====================================================================== 
Reported By:                Jean Porcherot
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11779
Category:                   CMake
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-01-31 16:38 EST
Last Modified:              2011-01-31 16:38 EST
====================================================================== 
Summary:                    FindQt4 fails because I re-organised my Qt folder
Description: 
- I download and compiled Qt 4.7.1, let's say from C:/Qt/4.7.1
- To make it easier for other developers from my company to use Qt, I then moved
the src/include/lib/bin folders to our internal SVN repository (I used to do
this with Qt 4.5.2 and an earlier cmake version). Then, all our developers can
use Qt without having to install it locally on their machine.
- Later, we try to have cmake work with a working copy checked-out from this
repository on a different machine (we cannot use the orginial folder where I
unzipped and compiled Qt sources). Let's say this working copy is in C:/MyWC, it
contains a sub folder (C:/MyWC/qt) with src/include/lib/bin Qt files copied
above, ready to be used.

Unfortunately some problems then appear:

1- FindQt4.cmake will fail to find qmake. One workaround could be to set QTDIR
but, for other reasons, I don't want to do that. Ideally, I would say that, if
QT_QMAKE_EXECUTABLE is already set, FIND_PROGRAM( QT_QMAKE_EXECUTABLE ... )
should not be called in FindQt4.cmake. This would make it easy, in my case, to
tell cmake where to fing qmake
2- Now I modified FindQt4.cmake as mentioned in (1-) above, I'm in face of a
harder problem. FindQt4.cmake asks qmake to tell where
lib/bin/include....folders are. And, obviously, qmake reports they are located
in C:/Qt/4.7.1, when I expect it to use them from C:/MyWC/qt, as C:/Qt/4.7.1 is
not present on this machine (I suppose this original Qt folder is hardly coded
in qmake, as I did not run any installer, this folder is not referenced in my
environement variable nor in my registry). I'm pretty sure there is a good
reason to do so, but, it would be great if, as a cmake user, I could force those
locations as I know where I want those files/folders to be picked from.

Personnaly, I modified FindQt4.cmake. I protected two statements as below:

line 460:
IF( NOT QT_QMAKE_EXECUTABLE ) # Added by Jean
# check for qmake
# Debian uses qmake-qt4
# macports' Qt uses qmake-mac
FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
 
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
  $ENV{QTDIR}/bin
  DOC "The qmake executable for the Qt installation to use"
)
ENDIF()

line 601;
IF (NOT QT_LIBRARY_DIR_TMP) #Test added by Jean
    _qt4_query_qmake(QT_INSTALL_LIBS QT_LIBRARY_DIR_TMP)
ENDIF()

Then, I invoke find_package as below:

set( QT_INCLUDE_DIR C:/MyWC/qt/include )
set( QT_HEADERS_DIR C:/MyWC/qt/include )
set( QT_LIBRARY_DIRC:/MyWC/qt/lib )
set( QT_BINARY_DIR C:/MyWC/qt/bin )
set( QT_LIBRARY_DIR_TMP ${QT_LIBRARY_DIR} )
set( QT_QMAKE_EXECUTABLE ${QT_BINARY_DIR}/qmake.exe )
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED )
set( QT_QTCORE_INCLUDE_DIR ${QT_INCLUDE_DIR} )

It works fine! So, I'm wondering if it would make sense to have those 2 small
changes I did in FindQt4.cmake be incorporated in the next cmake release. To
make FindQt4.cmake behaviour customizable. Let the cmake script setup the whole
Qt/Cmake variables, but, have a way to force the Qt original sources/include/lib
and bin major locations on disk.

If there is an alternative solution, I would be glad to know it....maybe I
missed a point... 

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-01-31 16:38 Jean Porcherot New Issue                                    
======================================================================




More information about the cmake-developers mailing list