如何使用 Qt 4.7 SDK 设置 Qt Creator 以在 Mac 上使用 CMake?

发布于 2024-11-19 16:40:25 字数 1401 浏览 3 评论 0原文

我在 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 库)。

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

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 所在的位置,但无论有或没有该行,都会出现同样的错误。

来自CMake的错误如下:

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

根据 本页

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

所以看起来 FindQt4.cmake 应该找到我暗示的 Qt4 它的位置——那么为什么它甚至会降到 Qt4Config.cmake 呢?有人可以通过标准安装在 Mac 上使用此功能吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

懒的傷心 2024-11-26 16:40:25

“find_package(Qt4...”命令非常依赖于查找 qmake 可执行文件。“qmake”在您的路径上吗?尝试类似

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

编辑:我想输入 QT_QMAKE_EXECUTABLE; 并且我一开始并没有理解您关于 CMAKE_MODULE_PATH 的声明。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文