CMake with Qt4 on Windows 8

A few days ago i installed Windows 8 on my desktop computer. Today i checked out some of my C++ projects to build them, but the *.vcproj file generation of CMake didn’t work, because of the following error message by the FindQt4.cmake script:

D:\Development\C++\ifcore\cmakebuild>cmake ..
-- Building for: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10
-- Check for working CXX compiler using: Visual Studio 10 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Warning at D:/Software/cmake-2.8.9-win32-x86/share/cmake-2.8/Modules/FindQ
t4.cmake:605 (MESSAGE):
  D:/Software/Qt/Desktop/Qt/4.8.1/msvc2010/bin/qmake.exe reported
  QT_INSTALL_LIBS as "Qt: Untested Windows version 6.2 detected!

  D:/Software/Qt/Desktop/Qt/4.8.1/msvc2010/lib" but QtCore could not be found
  there.  Qt is NOT installed correctly for the target build environment.
Call Stack (most recent call first):
  CMakeLists.txt:7 (FIND_PACKAGE)

CMake Error at D:/Software/cmake-2.8.9-win32-x86/share/cmake-2.8/Modules/FindQt4
.cmake:609 (MESSAGE):
  Could NOT find QtCore.  Check
  D:/Development/C++/ifcore/cmakebuild/CMakeFiles/CMakeError.log for more
  details.
Call Stack (most recent call first):
  CMakeLists.txt:7 (FIND_PACKAGE)

-- Configuring incomplete, errors occurred!

After some time on Google i found an bug report (#0013489) about this issue, which is already solved but not in my installed CMake Version 2.8.9. The bug report has a simple patch attached which replaces a single line in the FindQt4.cmake script.

This is how you fix your script:

  1. Open file: %CMAKE%\share\cmake-2.8\Modules\FindQt4.cmake
  2. Search for: OUTPUT_VARIABLE output ERROR_VARIABLE output
  3. Replace the line with: OUTPUT_VARIABLE output

Now everything should work fine.

One thought on “CMake with Qt4 on Windows 8

Leave a Reply

Your email address will not be published.


nine + 7 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>