CMake 找不到 Qt5QuickCompiler

Gré*_*rel 5 qt cmake qtquick2

我正在尝试使用 构建一个Qt Quick Controls应用程序CMake。我使用以下文档:

http://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html

运行时CMake,我收到此错误:

By not providing "FindQt5QuickCompiler.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "Qt5QuickCompiler", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5QuickCompiler"
  with any of the following names:

    Qt5QuickCompilerConfig.cmake
    qt5quickcompiler-config.cmake
Run Code Online (Sandbox Code Playgroud)

在这一行:

FIND_PACKAGE(Qt5QuickCompiler)
Run Code Online (Sandbox Code Playgroud)

显然CMake没有找到Qt5QuickCompiler。我检查了我的Qt文件夹 (C:\Qt),但它不在那里。但我可以使用QMake.

我需要设置什么才能找到Qt5QuickCompiler

rbr*_*rbr 5

我刚刚在 Linux 下的 Qt 5.12 中偶然发现了同样的问题。https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html下的文档目前似乎是错误的。

在 Qt5 中使用QuickCompilerafter而不是尝试通过. 改编链接中的示例,使用COMPONENTSfind_packagefind_package(Qt5QuickCompiler)

find_package(Qt5 COMPONENTS Quick Core Network QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
Run Code Online (Sandbox Code Playgroud)

代替

find_package(Qt5 COMPONENTS Quick Core Network)
find_package(Qt5QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
Run Code Online (Sandbox Code Playgroud)


ixS*_*Sci 2

错误非常明显:CMake 没有供 Qt5QuickCompiler 找到它的模块。它只是不知道它是什么。我刚刚检查了相应的cmake文件夹,没有该文件。我不确定 Qt 文档页面在谈论什么,但 CMake 发行版中没有这样的文件。也许 Qt 源在某个地方有这个文件?