[CMake] Two bugs, Three patches, no weddings and no funeral. (Qt)

William A. Hoffman billlist at nycap.rr.com
Tue Aug 23 12:48:52 EDT 2005


It is sounding like the idea of a FindQt.cmake is a bad one.
Perhaps we should only support FindQt3.cmake and FindQt4.cmake,
and if you do FindQt, it does qt3 for backwards compatibility.

That being said if QT4 is in your path, then cmake is doing the
right thing, and it is your path that is wrong.   If you want
to use an older version, then you will have to set QT_QMAKE_EXECUTABLE
by hand, either in CMakeSetup, ccmake, or an initial cache.
IF the QT_MAX_VERSION does not match the QT_QMAKE_EXECUTABLE that was
found an error should be flagged, instructing a user to change
QT_QMAKE_EXECUTABLE in the cache.

-Bill


At 12:37 PM 8/23/2005, John Biddiscombe wrote:
>I've just updated cmake from cvs and have set
>QT_MAX_VERSION 3.9.9
>
>and in environment
>QTDIR=c:\qt\3.2.1
>
>but cmake still pulls in qt4. I see from looking at the findQt module that a lot of checking is done on various variables, but the QT_MAX_VERSION has no effect because the first thing findQt does is to
> FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QTDIR}/bin)
>and since qt4 put itself on my path when it was installed - it gets found, once this has been located, later we have
>   EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
>     ARGS "-query QT_INSTALL_HEADERS"
>     OUTPUT_VARIABLE qt_headers )
>which reports itself again as qt4 and ensures that other checks don't find qt 3.2.1
>
>[I would like to use Qt3 even though Qt4 is installed (old projects, you know...). ]
>
>The find Qt code from there on will never find Qt3 no matter what you ask it to do, so and despite a remarkably long piece of code which checks QT_MAX_VERSION against the version found (which doesn't seem to do anything), it can't override the qt4 with qt3 because it never found it. In fact, if v4 is installed, it's unlikely one can find v3 without some intervention.
>
>I've therefore added a QT_SUGGESTED_PATH which can be set before calling FindQt. This will be searched before the other paths to help us get the version we want. [Only useful if you already know where it is, but one can add a gui option on a project by project as needs basis].
>Unfortunately, even if we fooled cmake into finding Qt in our suggested place, later on, when FindQt3 is run, it also uses find_program - and so uic.exe and moc.exe from qt4 are picked up (groan!). I've added the suggested patch to them too.
>
>But to cap it off,
>   FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS ${QT_USER_PATH}/bin $ENV{QTDIR}/bin)
>should search qt user path before system paths (according to docs), but I had to add NO_SYSTEM_PATH for it to work. It turns out that systemtools is adding the sytem path before the user paths. Changing this may have repurcussions beyond this fix...
>
>JB
>Attached are patches (cvs write access gone for me it seems).
>
>
>
>
>Index: Source/kwsys/SystemTools.cxx
>===================================================================
>RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
>retrieving revision 1.130
>diff -u -r1.130 SystemTools.cxx
>--- Source/kwsys/SystemTools.cxx        17 Aug 2005 21:04:23 -0000      1.130
>+++ Source/kwsys/SystemTools.cxx        23 Aug 2005 16:29:00 -0000
>@@ -1910,14 +1910,15 @@
>     }
>   kwsys_stl::vector<kwsys_stl::string> path;
>   SystemTools::GetPath(path, "CMAKE_PROGRAM_PATH");
>+
>+  // add the additional paths
>+  path.insert(path.end(), userPaths.begin(), userPaths.end());
>   // Add the system search path to our path.
>   if (!no_system_path)
>     {
>     SystemTools::GetPath(path);
>     }
>   
>-  // now add the additional paths
>-  path.insert(path.end(), userPaths.begin(), userPaths.end());
>   
>   for(kwsys_stl::vector<kwsys_stl::string>::const_iterator p = path.begin();
>       p != path.end(); ++p)
>
>Index: Modules/FindQt.cmake
>===================================================================
>RCS file: /cvsroot/CMake/CMake/Modules/FindQt.cmake,v
>retrieving revision 1.39
>diff -u -r1.39 FindQt.cmake
>--- Modules/FindQt.cmake        10 Aug 2005 12:48:03 -0000      1.39
>+++ Modules/FindQt.cmake        23 Aug 2005 16:09:37 -0000
>@@ -6,6 +6,8 @@
> #                                       Qt > 3 projects have to (!) set QT_MAX_VERSION (maximum by Trolltech is "15.7.99")
> # QT_MIN_VERSION                ,minimum Qt version set by YOU (e.g. "2.2.3")
> #
>+# QT_SUGGESTED_PATH                  ,Set this to a directory if you already know which version of Qt you want
>+#                                and would like to override the detection of installed versions 
> # This modules sets
> # QT_INST_MAJOR_VERSION         ,major number of the installed Qt (e.g. Qt-Version = 4.2.6 => 4)
> # QT_INST_MINOR_VERSION         ,minor number of the installed Qt (e.g. Qt-Version = 4.2.6 => 2)
>@@ -24,7 +26,11 @@
> 
> # check for qmake
> IF(NOT QT_QMAKE_EXECUTABLE)
>-  FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QTDIR}/bin)
>+  IF(QT_SUGGESTED_PATH)
>+    FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS ${QT_SUGGESTED_PATH}/bin $ENV{QTDIR}/bin NO_SYSTEM_PATH)
>+  ELSE(QT_SUGGESTED_PATH)
>+    FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QTDIR}/bin)
>+  ENDIF(QT_SUGGESTED_PATH)
> ENDIF(NOT QT_QMAKE_EXECUTABLE)
> 
> # compatibility to CMakeList.txt files for Qt3 projects
>
>Index: Modules/FindQt3.cmake
>===================================================================
>RCS file: /cvsroot/CMake/CMake/Modules/FindQt3.cmake,v
>retrieving revision 1.1
>diff -u -r1.1 FindQt3.cmake
>--- Modules/FindQt3.cmake       15 Jul 2005 16:14:47 -0000      1.1
>+++ Modules/FindQt3.cmake       23 Aug 2005 16:18:48 -0000
>@@ -95,6 +95,7 @@
> FIND_PROGRAM(QT_MOC_EXECUTABLE 
>   NAMES moc moc-qt3
>   PATHS
>+  ${QT_SUGGESTED_PATH}/bin
>   $ENV{QTDIR}/bin 
>   /usr/local/qt/bin
>   /usr/lib/qt/bin
>@@ -109,6 +110,7 @@
> ENDIF(QT_MOC_EXECUTABLE)
> 
> FIND_PROGRAM(QT_UIC_EXECUTABLE uic
>+  ${QT_SUGGESTED_PATH}/bin
>   $ENV{QTDIR}/bin 
>   /usr/local/qt/bin
>   /usr/lib/qt/bin
>
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list