Since 4.8.0 is out, I've reinstalled Qt, and now I want to use cmake too. To make cmake work, I remember having to add the mingw bin folder (QtSDK\Desktop\Qt\4.7.3
) to PATH back in Qt4.7.3, so I guessed that there would be a similar folder in QtSDK\Desktop\Qt\4.8.0
now but this is not the case. My question is, does anybody else have experience with setting up Qt and cmake? I could use some help right now, as I've googled for a bit and was unable to find any ways to make cmake work.
When trying to build, I get this well known message:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
Could NOT find Qt4 (missing: QT_QMAKE_EXECUTABLE QT_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindQt4.cmake:1171 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:3 (find_package)
I had this problem for a slightly different reason. Maybe this will help someone else:
I uninstalled Qt 4.8.3 and then installed qt 4.8.4. Based on Slava's answer I discovered that CMake is getting the value of $(qt_install_version} from:
This was still set to 4.8.3 even though all the other registry entries were updated to 4.8.4. Changing the value of the DefaultVersion key to 4.8.4 fixed the problem for me.
I had the same problem and I solved providing the path to qmake,
On Mac, while the binaries are saved in
/usr/local/Trolltech/Qt-4.8.7/bin
the required qmake required as value of QT_QMAKE_EXECUTABLE is, for my OS, stored in the path/opt/qt-4.8.7/bin/qmake
. Hope this help as well.You just need to set the path to qmake in
QT_QMAKE_EXECUTABLE
, and then cmake can useqmake -query
to find all the other paths it needs (similar to pkg-config on Linux).Steps for building a project using Qt and CMake usually are:
cmd
andcd
into build folder e.g.cd build\project
cmake-gui ..\..\source\project
QT_QMAKE_EXECUTABLE
andCMAKE_BUILD_TYPE
cmake --build .
So, I found out what was the problem, and I think I should have known before. I simply added
C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin
to my PATH variable. It may be useful to note that, in a default 4.8.0 install, qmake is located inC:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin
as opposed toC:\QtSDK\Desktop\Qt\4.7.3\mingw\bin
in 4.7.3. Notice the difference;msvc2010
vsmingw
. It's actually glaringly obvious, asmsvc2010
was the only folder in that directory.I didn't try skyhisi's answer as it was no longer needed, but I'm guessing that it's another correct (if not better) way to make cmake work.
Just ran into the same problem... Take a look into findQt4.cmake
You can either alter registry keys, or, I personally prefer deleting all those keys altogether and modify $ENV{QTDIR} variable. Good luck.