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.
  • 2019-01-11 16:26
  • 378
请先 登录 后评论

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

请先 登录 后评论