如何通过Qt 4.7 SDK在Mac上设置Qt Creator与CMake一起使用? [英] How to setup Qt Creator to work with CMake on Mac with Qt 4.7 SDK?

查看:275
本文介绍了如何通过Qt 4.7 SDK在Mac上设置Qt Creator与CMake一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MacOS X 10.6.8下使用Qt Creator 2.2.1,为CMake 2.8.5安装了标准MacOS X,并在6月21日发布了Qt SDK版本1.1.2(Qt 4.7.3库).

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).

我的CMakeLists.txt在Qt4的find_package中失败-第二行:

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)

我添加了第一个,只是为了确保它知道FindQt4.cmake的位置,但是无论有无该行,都存在相同的错误.

I added the first just to make sure it knew where FindQt4.cmake lives, but same error either with or without that line.

CMake的错误如下:

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

我已经在安装的QtSDK位置和CMake目录中找到了一些发现,并且没有Qt4Config.cmake.我确实在CMake模块目录中看到了-FindQt4.cmake,Qt4ConfigDependentSettings.cmake和UseQt4.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

根据此页面:

find_package()命令将在模块路径中查找Find.cmake, 这是查找库的典型方法.首先CMake检查所有目录 $ {CMAKE_MODULE_PATH},然后它会在自己的模块目录中查找 /share/cmake-x.y/Modules/. 如果找不到这样的文件,它将查找Config.cmake或 -config.cmake,应该由库安装 (但是目前还没有很多库可以安装它们)和 不进行检测,而是仅包含针对 已安装的库.

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.

因此,似乎FindQt4.cmake应该找到我要提示的Qt4位置-那么为什么还要将其简化为Qt4Config.cmake?任何人都可以在标准安装的Mac上使用它吗?

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?

推荐答案

"find_package(Qt4 ...)"命令非常依赖于查找qmake可执行文件.路径中是否包含"qmake"? >

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)

我的意思是键入QT_QMAKE_EXECUTABLE;一开始我并没有理解您关于CMAKE_MODULE_PATH的声明.

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

这篇关于如何通过Qt 4.7 SDK在Mac上设置Qt Creator与CMake一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆