簡體   English   中英

CMakeLists includeT Qt5::QML 不起作用

[英]CMakeLists includeT Qt5::QML does not work

這是我的 CMakelists.txt 文件。

cmake_minimum_required(VERSION 3.0.2)
project(osm_map)
find_package(catkin REQUIRED COMPONENTS rviz)

find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(QT_LIBRARIES Qt5::Widgets Qt5::Qml)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(SRC_FILES
  src/core.cpp
)

add_library(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})

當我嘗試使用catkin_make -Wno-dev --only-pkg-with-deps osm_map編譯我的項目時,它似乎找到了 QT 的每個模塊(我還測試了下面未顯示的其他模塊)但沒有找到 QML。錯誤消息:

CMake Error at osm_map/CMakeLists.txt:53 (target_link_libraries):
  Target "osm_map" links to:

    Qt5::Qml

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

QT QML 安裝在我的系統上,路徑為/usr/include/x86_64-linux-gnu/qt5/QtQml並包含必要的標頭。 以及為什么我能做的想法? QT 的find_package調用應該找到 QT 附帶的所有庫和標頭,也許這是 QML 無法正常工作的部分?

問題出在你

find_package(Qt5 COMPONENTS Widgets REQUIRED)

在這里你問 CMake 你想要 Qt5 的 Widgets 組件但是你告訴它鏈接到你沒有要求的 Qml。

您應該將其更改為以下內容:

find_package(Qt5 COMPONENTS Widgets Qml REQUIRED)

暫無
暫無

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

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