windows下,用CMake编译qt项目,出现错误By not providing “FindQt5.cmake“...

开发环境:windows10 + qt5.14, 编译器msvc2017x64,CMake3.30;

现象:

CMakeList文件里,如有find_package(Qt5 COMPONENTS Widgets REQUIRED)

target_link_libraries(dis_lib PRIVATE Qt5::Widgets)

用CMake生成工程时候,会有如下错误:

CMake Error at CMakeLists.txt:69 (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.

解决方法:

1.在qt安装目录搜索Qt5Config.cmake,找到文件路径;

2.在系统环境变量-用户变量里,添加Qt5_DIR=文件路径;如下图,然后保存

3.重新CMake即可;

以上;

原创,转载请注明出处;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值