How to configure Qt Creator to work with CMake on Mac with Qt 4.7 SDK?

I am using Qt Creator 2.2.1 under MacOS X 10.6.8, the standard MacOS X installation for CMake 2.8.5 and Qt SDK version 1.1.2 released on June 21 (Qt 4.7.3 libraries).

My CMakeLists.txt does not work in find_package for Qt4 - the second of the lines below:

set (CMAKE_MODULE_PATH /Applications/CMake 2.8-5.app/Contents/share/cmake-2.8/Modules) find_package (Qt4 REQUIRED HINTS /Users/myname/QtSDK) 

I added the first one to make sure that he knows where FindQt4.cmake lives, but the same error either with this line or without it.

The CMake error is as follows:

  - Configuring incomplete, errors occurred!
      CMake Error at CMakeLists.txt: 30 (find_package):
      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

I made several finds in both the installed QtSDK location and the CMake directories, and there is no Qt4Config.cmake there. I saw in the CMake module directory - FindQt4.cmake, Qt4ConfigDependentSettings.cmake and UseQt4.cmake

According to this page :

The find_package () command will look for the module path for Find.cmake, which is a typical way to find libraries. The first CMake checks all directories in $ {CMAKE_MODULE_PATH}, then it looks in its own module directory / share / cmake -xy / Modules /. If such a file is not found, it searches for Config.cmake or -config.cmake, which should be installed by the libraries (but there are still not many libraries that install them) and which do not perform detection, but simply contain hard-set values ​​for the installed libraries.

So, it looks like FindQt4.cmake should find Qt4, I'm hinting at its location - so why does it even do this before Qt4Config.cmake? Can anyone make this work on a Mac with these default settings?

+4
source share
1 answer

The find_package (Qt4 ...) command is very dependent on finding the qmake executable. "qmake" in your way? Try something like

 set(QT_QMAKE_EXECUTABLE "<actual location of qmake on your system>") find_package(Qt4 REQUIRED) 

Edit: I wanted to dial QT_QMAKE_EXECUTABLE; and at first I did not try your statement about CMAKE_MODULE_PATH.

+3
source

All Articles