这是我的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工作不正常的部分?
1条答案
按热度按时间vq8itlhq1#
问题出在你
find_package(Qt5 COMPONENTS Widgets REQUIRED)
这里你问CMake你想要Qt5的Widget组件,但是你告诉它与Qml链接,你没有要求。
应将其更改为以下内容:
find_package(Qt5 COMPONENTS Widgets Qml REQUIRED)