未知的CMake Qt5命令
我目前正在尝试使用CMake构建一个项目。 这是我得到的输出未知的CMake Qt5命令,cmake,qt5,Cmake,Qt5,我目前正在尝试使用CMake构建一个项目。 这是我得到的输出 CMake Warning at ext/quazip/CMakeLists.txt:4 (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
CMake Warning at ext/quazip/CMakeLists.txt:4 (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 Error at ext/quazip/CMakeLists.txt:19 (qt5_wrap_cpp):
Unknown CMake command "qt5_wrap_cpp".
我已经安装了Qt Creator,我不确定为什么会出现此错误。
我在网上四处看看,他们说我应该补充
set(QT_USE_QTXML true)
FIND_PACKAGE(Qt5)
在ext/quazip/CMakeLists.txt中的#项目之后
我已经这样做了,但我仍然得到这个错误的任何建议
更新:
因此,我在我的顶级CMakeLists.txt中添加了以下内容
find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )
find_package( Qt5OpenGL REQUIRED )
find_package( Qt5Multimedia REQUIRED )
find_package( Qt5WebKitWidgets REQUIRED )
find_package( Qt5Xml REQUIRED )
#### Qt5
find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )
find_package( Qt5OpenGL REQUIRED )
find_package( Qt5Multimedia REQUIRED )
find_package( Qt5WebKitWidgets REQUIRED )
find_package( Qt5Xml REQUIRED )
set( CMAKE_AUTOMOC ON ) # to automoc remove the need to wrap by hand
我清除了缓存,然后进行了配置。在这一点上,我得到以下错误
CMake Error at CMakeLists.txt:3 (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
Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
"Qt5Core_DIR" to a directory containing one of the above files. If
"Qt5Core" provides a separate development package or SDK, be sure it has
been installed.
Configuring incomplete, errors occurred!
要在CMakeLists.txt中使用
Qt5
,您应该使用(组合)这些功能:
在顶级CMakeLists.txt中
find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )
find_package( Qt5OpenGL REQUIRED )
find_package( Qt5Multimedia REQUIRED )
find_package( Qt5WebKitWidgets REQUIRED )
find_package( Qt5Xml REQUIRED )
#### Qt5
find_package( Qt5Core REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Gui REQUIRED )
find_package( Qt5OpenGL REQUIRED )
find_package( Qt5Multimedia REQUIRED )
find_package( Qt5WebKitWidgets REQUIRED )
find_package( Qt5Xml REQUIRED )
set( CMAKE_AUTOMOC ON ) # to automoc remove the need to wrap by hand
编辑:
Qt5 cmake模块由Qt5本身提供,因此您需要告诉cmake在哪里可以找到qt。请参阅。使用
qt5\u使用模块
是错误的。它仅适用于CMake 2.8.9和2.8.10的用户,而不适用于其他用户。