1 CMAKE 无法找到已经安装了的 QT5,应该如何配置?

macOS 中使用 CMAKE 编译时出现无法找到 QT5CORE 错误,但实际已经安装了 QT5,应该如何配置 CMAKE 呢?

Could not find a package configuration file provided by "QT5Core" with any
  of the following names:
    QT5CoreConfig.cmake
    QT5core-config.cmake
  Add the installation prefix of "QT5Core" to CMAKE_PREFIX_PATH or set
  "QT5Core_DIR" to a directory containing one of the above files.  If
  "QT5Core" provides a separate development package or SDK, be sure it has
  been installed.
  • 13441
请先 登录 后评论

1 个回答

XY - 开发者 @ 学研谷
擅长:LS-DYNA,AUTODYN

已经安装了 QT5 使用 CAMKE 会出现 QT5_DIR-NOTFOUND 的错误,需要手动配置 QT5 的路径。

配置方法是在 CMAKE 中,QT5Core_DIR 指向 QT 安装路径下的 QT/5.11.1/clang_64/lib/cmake;

配置如图所示:

attachments-2019-01-ZxTuhRZH5c3854cfa5618.jpg

也可以在 CMAKELIST.TXT 中的 CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR) 下加入安装路径,如下所示:

CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR)
set(QT5_DIR“/Users/chenshuai/QT/5.11.1/clang_64/lib/cmake”)

请先 登录 后评论