错误信息:
D:\Qt\Examples\Qt-6.6.3\demos\mediaplayer\CMakeLists.txt:13: error: By not providing "FindQt6.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt6", but CMake did not find one.
Could not find a package configuration file provided by "Qt6" (requested version 6.6) with any of the following names:
Qt6Config.cmake
qt6-config.cmake
Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR" to a directory containing one of the above files. If "Qt6" provides a separate development package or SDK, be sure it has been installed.
解决方案:
选择项目选项,在构建设置中,配置QT使用的CMake。选择kit configuration选项,配置CMake Tool为安装QT时附带安装的CMake。完成以上配置后,Qt Creator中示例可以正常运行。
碎碎念:因为在安装QT之前,我的系统上已经安装有CMake。Qt Creator中开始默认使用的是我之前安装的CMake,然后编译时就出现了这个报错。换成随Qt一起安装的CMake后,问题解决,至于原因,作为初学者我也不是很明白。谨作此文,记录报错及解决过程。