[CMake] Finding Qt4 binaries under Windows

Pau Garcia i Quiles pgquiles at elpauer.org
Fri Aug 21 16:48:47 EDT 2009


On Fri, Aug 21, 2009 at 10:31 PM, John Drescher<drescherjm at gmail.com> wrote:
>> So, if you compiled to C:\Qt\4.5.1 then you have a couple of options:
>>
>> set QTDIR to C:\Qt\4.5.1 in the environment variables.
>>
>> OR
>>
>> find_package(Qt4 PATHS "C:/Qt/4/.5.1") like Pau suggested.
>>
>> If you don't like the version number on there then recompile Qt 4.5.1 so
>> that it has a path of C:\Qt and NOT C:\Qt\4.5.1
>>
>
> I just let cmake-gui try to find it and when it fails I manually set
> the location of the qmake executable. This way I can have more than 1
> Qt version installed and I do not have to play with environment
> variables to switch between versions. After telling cmake-gui where
> qmake.exe is for a project it will never ask me again unless I clear
> the cache. I guess I could create a batch file that launches cmake-gui
> with a different environment to do this but its not like I do this
> ever day..

It's late and I'm tired but I'd say you need to:

- Run regedit and remove
HKEY_CURRENT_USER\Software\Trolltech\Versions\DefaultQtVersion, if you
have if, because this is where the default QT version is picked from.

- Take a look at qt.conf ( http://doc.trolltech.com/4.5/qt-conf.html )
because I've got the feeling the paths qmake is returning in your
machine are not the actual paths

- Call CMake like this: "cmake
-DQT_QMAKE_EXECUTABLE:FILEPATH=C:/Qt/4.5.1/bin/qmake.exe", or whatever
you want, so that you don't need to use the GUI to edit the cache and
CMake does not need to look for Qt twice (first time and fail, then
after you tell CMake the actual path to QMake). This way you can have
several versions of Qt installed and you don't need to play with
environment variables.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


More information about the CMake mailing list