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

旧街凉风 提交于 2019-12-23 15:13:36

问题


I'm using Qt Creator 2.2.1 under MacOS X 10.6.8, standard MacOS X install for CMake 2.8.5 and Qt SDK version 1.1.2 released on June 21st (Qt 4.7.3 libraries).

My CMakeLists.txt fails in the 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 just to make sure it knew where FindQt4.cmake lives, but same error either with or without that line.

The error from CMake 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've done some finds in both the installed QtSDK location and the CMake directories, and there's no Qt4Config.cmake. I did see in the CMake module directory -- FindQt4.cmake, Qt4ConfigDependentSettings.cmake, and UseQt4.cmake

According to this page:

The find_package() command will look in the module path for Find.cmake, which is the typical way for finding libraries. First CMake checks all directories in ${CMAKE_MODULE_PATH}, then it looks in its own module directory /share/cmake-x.y/Modules/. If no such file is found, it looks for Config.cmake or -config.cmake, which are supposed to be installed by libraries (but there are currently not yet many libraries which install them) and that don't do detection, but rather just contain hardcoded values for the installed library.

So it seems like FindQt4.cmake should find the Qt4 I'm hinting at its location -- so why is it even making it down to Qt4Config.cmake? Anyone get this to work on Mac with those standard installs?


回答1:


The "find_package(Qt4..." command is very dependent on finding a qmake executable. Is "qmake" on your path? Try something like

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

Edit: I meant to type QT_QMAKE_EXECUTABLE; and I did not grok your statement about CMAKE_MODULE_PATH at first.



来源:https://stackoverflow.com/questions/6658691/how-to-setup-qt-creator-to-work-with-cmake-on-mac-with-qt-4-7-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!