更新了Qt库;不能再建造了

时间:2017-08-19 10:19:18

标签: c++ macos qt build cmake

我有一个以前工作的Qt5 / cmake项目,它很好。然后我将Qt从5.6更新到5.8。现在cmake再也找不到Qt了。

这是我的CMakeLists.txt文件:

cmake_minimum_required(VERSION 3.0)
project(TEST)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_PREFIX_PATH "/opt/Qt/Qt5.8.0")
set(QT_QMAKE_EXECUTABLE ${CMAKE_PREFIX_PATH}/5.8/clang_64/bin/qmake)

find_package(Qt5Widgets)
...

这是我收到的错误消息:

CMake Warning at CMakeLists.txt:56 (find_package):
  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Qt5Widgets", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5Widgets" with
  any of the following names:

    Qt5WidgetsConfig.cmake
    qt5widgets-config.cmake

  Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
  "Qt5Widgets_DIR" to a directory containing one of the above files.  If
  "Qt5Widgets" provides a separate development package or SDK, be sure it has
  been installed.

我遵循了Qt documentation中的内容,所以我不明白出了什么问题。

版本细节:
- cmake 3.9.0
- Qt 5.8.0
- QMake 3.1
- Mac OS X 10.9.5

2 个答案:

答案 0 :(得分:0)

您是否检查过与QT兼容的CMake版本?你也检查过qmake一切正常吗?因为这是大多数时候引起问题的原因。检查QT_QMAKE_EXECUTABLE是否指向新的QT版本,我总是遇到新版QT的问题。

答案 1 :(得分:0)

修正了以下系统变量的设置:

QTDIR=/opt/Qt/Qt5.8.0/5.8/clang_64
PATH=$PATH:/opt/Qt/Qt5.8.0/5.8/clang_64/bin

并删除:

set(CMAKE_PREFIX_PATH "/opt/Qt/Qt5.8.0")

来自CMakeLists.txt。