报错内容
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
cmake
原因解析
找不到Qt模块,原因是cmake path配置错误
解决方案
- 确认模块是否安装
检查mingw模块安装情况,如果没有安装,需要在重新安装时勾选Mingw,版本有32bit和64bit,依据系统选择
- 确认项目cmake配置
方法一:在创建项目时,设置Qt CMake prefix path为你的安装路径+mingw路径
例如:"D:/Qt/Qt5.12.12/5.12.12/mingw73_64"
方法二:
修改CMakeLists.txt
set(CMAKE_PREFIX_PATH "D:/Qt/Qt5.12.12/5.12.12/mingw73_64")
cmake