这是我的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)
。我认为你需要find_package(Qt5 COMPONENTS Widgets Qml REQUIRED)
以及可能其他一些组件。 - drescherjm