簡體   English   中英

CMake 找不到 Qt5QuickCompiler

[英]CMake doesn't find Qt5QuickCompiler

我正在嘗試使用CMake構建Qt Quick Controls應用程序。 我使用以下文檔:

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

在這一行:

FIND_PACKAGE(Qt5QuickCompiler)

顯然CMake沒有找到Qt5QuickCompiler 我檢查了我的Qt文件夾 (C:\\Qt) 但它不在那里。 但是我可以用QMake運行這個應用程序。

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

我只是在 Linux 下偶然發現了 Qt 5.12 的相同問題。 https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html下的文檔目前似乎是錯誤的。

在 Qt5 find_package中的COMPONENTS之后使用QuickCompiler而不是嘗試通過find_package(Qt5QuickCompiler)添加它。 改編鏈接中的示例,使用

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

代替

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

錯誤很明顯:CMake 沒有讓 Qt5QuickCompiler 找到它的模塊。 它只是不知道它是什么。 我剛剛檢查了相應的 cmake 文件夾,它沒有那個文件。 我不確定 Qt 文檔頁面在談論什么,但 CMake 發行版中沒有這樣的文件。 也許 Qt 源在某處有這個文件?

您需要使用 Qt Quick 編譯器構建 Qt5,您可以從http://www.qt.io/qt-quick/下載。 在 Qt Quick 編譯器的 build 目錄下,你會發現Qt5QuickCompilerConfig.cmake
將路徑復制到這個目錄,並像這樣添加到CMAKE_PREFIX_PATH

cmake -DCMAKE_PRFEIX_PATH=<pathToFile> <pathToSrcDirOfYourProject>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM