Catkin/CMake Bundling for Snapcraft "Qrc module is not installed"
I'm working on bundling a ROS + Qt5 application into a snap - and can't seem to get all of the qt dependencies properly included. I would love to get some input on where I might be going wrong. I'm not certain if my problem is in Catkin/CMake, or Snapcraft.
Installing and running the snap launches the ROS nodes with no apparent issues. The Qt app; however, failes to open, giving me this:
QQmlImportDatabase::addImportPath: "/usr/lib/x86_64-linux-gnu/qt5/qml"
QQmlImportDatabase::addImportPath: "/snap/demine-control-station/x1/usr/lib/x86_64-linux-gnu/qt5/qml"
QQmlImportDatabase::addImportPath: "/snap/demine-control-station/x1/lib/x86_64-linux-gnu"
QQmlImportDatabase::addImportPath: "/snap/demine-control-station/x1/opt/ros/kinetic/lib/demine_control_station"
QQmlApplicationEngine failed to load component
qrc:/main_window.qml:2 module "QtQuick.Window" is not installed
qrc:/main_window.qml:4 module "Ros" is not installed
qrc:/main_window.qml:1 module "QtQuick" is not installed
qrc:/main_window.qml:2 module "QtQuick.Window" is not installed
qrc:/main_window.qml:4 module "Ros" is not installed
qrc:/main_window.qml:1 module "QtQuick" is not installed
qrc:/main_window.qml:2 module "QtQuick.Window" is not installed
qrc:/main_window.qml:4 module "Ros" is not installed
qrc:/main_window.qml:1 module "QtQuick" is not installed
The qml
folder it's looking for doesn't exist in /snap/demine-control-station/x1/usr/lib/x86_64-linux-gnu/qt5/
, which contains:
plugins
On my local machine; however, /usr/lib/x86_64-linux-gnu/qt5/
contains:
bin libexec mkspecs plugins qml
So - this leads me to believe that either I've either got my snapcraft.yaml
wrong, or I'm missing an install()
in my CMakelists.txt
.
My understanding is that the find_package()
, add_executable()
, target_link_libraries()
and, in the case of a qt app, qt5_use_modules()
tell cmake what to install when I call install()
on the project executable.
I'm still fairly inexperienced with cmake and Qt, and unfortunately a few full days of trial and error and digging through documentation hasn't cut it to figure out what I'm doing wrong. I did find this sage nugget though:
"Most ROS developers run out of the devel space. As a result, it's easy to forget the importance of good install rules"
(https://docs.snapcraft.io/build-snaps/ros)
Thanks a bunch!
Here is my CMakeLists.txt
:
cmake_minimum_required(VERSION 2.8.8)
project(demine_control_station)
add_compile_options(-std=c++11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
##############################################################################
# Catkin
##############################################################################
find_package(catkin REQUIRED COMPONENTS qt_build roscpp sensor_msgs image_transport)
set(QML_IMPORT_PATH "${QML_IMPORT_PATH};${CATKIN_GLOBAL_LIB_DESTINATION}" )
set(QML_IMPORT_PATH2 "${QML_IMPORT_PATH};${CATKIN_GLOBAL_LIB_DESTINATION}" )
include_directories(${catkin_INCLUDE_DIRS})
catkin_package()
##############################################################################
# Qt Environment
##############################################################################
find_package(Qt5 COMPONENTS Core Gui Qml Quick REQUIRED)
##############################################################################
# Sections
##############################################################################
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/${PROJECT_NAME}/*.hpp)
QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT5_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
##############################################################################
# Sources
##############################################################################
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
##############################################################################
# Binaries
##############################################################################
add_executable(${PROJECT_NAME} ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
qt5_use_modules(${PROJECT_NAME} Quick Core)
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC include)
##############################################################################
# Installs
##############################################################################
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(
DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
And my snapcraft.yaml
:
grade: devel
confinement: devmode
apps:
control-station:
environment:
QT_DEBUG_PLUGINS: 1
QML_IMPORT_TRACE: 1
command: desktop-launch roslaunch demine_control_station demine_control_station.launch ...