MantisBT - CMake
View Issue Details
0011789CMakeCMakepublic2011-02-03 03:332011-02-04 10:49
Jean Porcherot 
Clinton Stimpson 
normalminoralways
closedwon't fix 
Win XP/Seven
CMake 2.8.3 
 
0011789: Unable to force a Qt version to be picked by cmake
Hi,

Earlier, I reported issue 0011779 (http://public.kitware.com/Bug/view.php?id=11779 [^]). James proposed a great solution that works...partially.

I Added the qt.conf.in and it works fine...unless there is a Qt version installed on the PC. As proposed, I set QTDIR to C:/code/sw/3rdparty/Qt/4.7.1/qt-win32-msvc2008, but, on the PC I run cmake from, the devlopper installed Qt 4.5.2 some time ago.

Then, FindQt4.cmake picks up the 4.5.2 version of Qt rather than the 4.7.1 I'm asking it to use through the QTDIR variable.

That's because, we check for the registry before we check for the QTDIR path (see below):

GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
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"
)

So, once again, I had to modify the FindQt4.cmake script by commenting the GET_FILENAME_COMPONENT line.

I'd rather not modify this file as the modification will be lost next time I'll upgrade cmake. Is there another way to workaround the problem from my CMakeLists.txt?

Thanks in davance

Jean
No tags attached.
related to 0011779closed Clinton Stimpson FindQt4 fails because I re-organised my Qt folder 
Issue History
2011-02-03 03:33Jean PorcherotNew Issue
2011-02-03 08:15Brad KingRelationship addedrelated to 0011779
2011-02-03 08:15Brad KingAssigned To => Clinton Stimpson
2011-02-03 08:15Brad KingStatusnew => assigned
2011-02-03 18:46Clinton StimpsonNote Added: 0025263
2011-02-04 05:49Jean PorcherotNote Added: 0025276
2011-02-04 10:49Clinton StimpsonNote Added: 0025282
2011-02-04 10:49Clinton StimpsonStatusassigned => closed
2011-02-04 10:49Clinton StimpsonResolutionopen => won't fix

Notes
(0025263)
Clinton Stimpson   
2011-02-03 18:46   
Typically, people put it in their PATH environment variable because they need their apps (that were just built) to find the Qt dlls at runtime.

The PATH environment variable has a higher priority than any of those paths in that find_program() call.

So that and CMAKE_PREFIX_PATH should probably be preferred as general ways to find things.
(0025276)
Jean Porcherot   
2011-02-04 05:49   
OK, adding set( CMAKE_PREFIX_PATH "$ENV{QTDIR}/bin" ) works well.

Thanks for your help and reactivity!

Jean
(0025282)
Clinton Stimpson   
2011-02-04 10:49   
closing.. as there are more general ways of telling cmake what you want found.