使用CMake构建文件时出现以下错误:
CMake Warning at CMakeLists.txt:33 (FIND_PACKAGE):
By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Core", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5Core" with any of the following names:
Qt5CoreConfig.cmake
qt5core-config.cmake
有谁知道如何解决这个问题?提前致谢
答案 0 :(得分:5)
您应该在Qt安装中找到cmake包:
<install_prefix>/lib/cmake
假设<install_prefix>
是您安装的根路径。在配置中将变量Qt5_DIR设置为<install_prefix>/lib/cmake/Qt5
,cmake应该能够找到所有模块
答案 1 :(得分:1)
也许,您应该尝试在环境或配置中添加CMAKE_PREFIX_PATH
变量的正确路径。
export CMAKE_PREFIX_PATH=path_to/Qt/5.9/clang_64:$CMAKE_PREFIX_PATH
将path_to
替换为您的真实路径。
答案 2 :(得分:0)
此错误消息的一个可能原因是过时的CMake代码,例如[1]
find_package(Qt5Core REQUIRED).
然后有一个很好的机会通过更改为
来解决问题find_package(Qt5 COMPONENTS REQUIRED Core).
[1] http://cmake.3232098.n2.nabble.com/debugging-CMAKE-PREFIX-PATH-td7596290.html
答案 3 :(得分:0)
很多时候足以正确设置PATH环境变量,因此在终端中键入qmake时,它将执行正确的文件。有了它后,在命令行中执行cmake