在使用CMake编译Qt 项目的时候,出现了一下错误。 记录一下解决方案,避免以后出现类似的问题。
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):
Could not find a package configuration file provided by "Qt5Quick" with any
of the following names:
Qt5QuickConfig.cmake
qt5quick-config.cmake
Add the installation prefix of "Qt5Quick" to CMAKE_PREFIX_PATH or set
"Qt5Quick_DIR" to a directory containing one of the above files. If
"Qt5Quick" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
Application/CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
解决方案:
1.找到Qt5 cmake 所在的目录
/home/ubuntu/tools/Qt5.12.0/5.12.0/gcc_64/lib/cmake
发现,我的电脑Qt钟cmake所在的目录,如上所示
2.添加编译选项解决如山问题
cmake -DCMAKE_PREFIX_PATH=/home/ubuntu/tools/Qt5.12.0/5.12.0/gcc_64/lib/cmake ..
set(CMAKE_PREFIX_PATH "/home/ubuntu/tools/Qt5.12.0/5.12.0/gcc_64/lib/cmake")
经过以上步骤,可以完美解决。
如果还出现如上错误, 那么,就需要检查下,对应的包是否存在, 如果不存在, 那么就需要安装全部的包。