[CMake] Finding Qt4 binaries under Windows

Michael Jackson mike.jackson at bluequartz.net
Fri Aug 21 15:14:30 EDT 2009


set QTDIR to C:\Qt\4.5.1

#  
------------------------------------------------------------------------------
#  Qt 4 Section
#  
------------------------------------------------------------------------------
# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
IF (WIN32)
     SET (QT_USE_QTMAIN TRUE)
ENDIF (WIN32)

# this command finds Qt4 libraries and sets all required variables
# note that it's Qt4, not QT4 or qt4
FIND_PACKAGE( Qt4 REQUIRED )

# add some useful macros and variables
# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that
# contains a path to CMake script)
INCLUDE( ${QT_USE_FILE} )

# Set the GUI type for different platforms
SET(GUI_TYPE )

# Set some Win32 Specific Settings
IF(WIN32)
  SET(GUI_TYPE WIN32)
ENDIF(WIN32)

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio

On Aug 21, 2009, at 2:31 PM, Sebastian Schuberth wrote:

> Hi,
>
> I'm trying to use CMake for a Windows application that links against  
> Qt 4. I've installed Qt 4.5.1 from sources (unzipped to the standard  
> location C:\Qt\4.5.1) and compiled it myself.
>
> As qmake is not in my PATH, I'm using
>
> ---8<---(snip)---
>
> cmake_minimum_required(VERSION 2.6.4)
>
> set(name "Qt Test")
> project(${name})
>
> file(GLOB_RECURSE sources "src/*.h" "src/*.cpp" "src/*.ui")
> add_executable(${name} ${sources})
>
> include(FindQt4)
> find_package(Qt4 PATHS "C:/Qt")
>
> ---8<---(snip)---
>
> to point CMake to the right directory. It seems to work, sort of,  
> but I'm getting the following error:
>
> ---8<---(snip)---
>
>  Could not find a configuration file for package Qt4.
>
>  Set Qt4_DIR to the directory containing a CMake configuration file  
> for Qt4.
>  The file will have one of the following names:
>
>    Qt4Config.cmake
>    qt4-config.cmake
>
> ---8<---(snip)---
>
> Why is CMake searching for such a file? Where should that file be  
> located? Do I need to create it?
>
> -- 
> Sebastian Schuberth
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list