ROS2 Humble with QML
-
Hi!
I'm having an issue when compiling the code.
I think the problem is with the paths because the CMakeLists.txt file doesn’t recognize the things related to Qt.cmake_minimum_required(VERSION 3.16) # Cambia a 3.16 o superior project(hello LANGUAGES CXX) # Configuraciones de CMake para Qt set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Encuentra los paquetes de Qt y ROS2 necesarios find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Core Gui Qml) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Core Gui Qml) find_package(rclcpp REQUIRED) find_package(ament_cmake REQUIRED) find_package(std_msgs REQUIRED) find_package(example_interfaces REQUIRED) find_package(geometry_msgs REQUIRED) # Agrega los archivos QML y de recursos qt_add_qml_module(example2 URI hello VERSION 1.0 QML_FILES qml/Home.qml qml/ApplicationFlow.qml qml/Colors.qml qml/Constants.qml qml/HomeForm.ui.qml qml/IP.qml qml/IPForm.ui.qml qml/main.qml RESOURCES images/logo.png ) # Define el ejecutable y especifica los archivos fuente add_executable(example2 main.cpp lib/rosnode.h src/rosnode.cpp src/utils.cpp lib/utils.h ) # Vincula las bibliotecas de Qt y ROS2 necesarias target_link_libraries(example2 Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Qml ) # Define las dependencias de ament para ROS2 ament_target_dependencies(example2 rclcpp std_msgs example_interfaces geometry_msgs ) # Configuración de instalación include(GNUInstallDirs) install(TARGETS example2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # Define el paquete ament ament_package()
And the path are this:
-
Hi!
I'm having an issue when compiling the code.
I think the problem is with the paths because the CMakeLists.txt file doesn’t recognize the things related to Qt.cmake_minimum_required(VERSION 3.16) # Cambia a 3.16 o superior project(hello LANGUAGES CXX) # Configuraciones de CMake para Qt set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Encuentra los paquetes de Qt y ROS2 necesarios find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick Core Gui Qml) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick Core Gui Qml) find_package(rclcpp REQUIRED) find_package(ament_cmake REQUIRED) find_package(std_msgs REQUIRED) find_package(example_interfaces REQUIRED) find_package(geometry_msgs REQUIRED) # Agrega los archivos QML y de recursos qt_add_qml_module(example2 URI hello VERSION 1.0 QML_FILES qml/Home.qml qml/ApplicationFlow.qml qml/Colors.qml qml/Constants.qml qml/HomeForm.ui.qml qml/IP.qml qml/IPForm.ui.qml qml/main.qml RESOURCES images/logo.png ) # Define el ejecutable y especifica los archivos fuente add_executable(example2 main.cpp lib/rosnode.h src/rosnode.cpp src/utils.cpp lib/utils.h ) # Vincula las bibliotecas de Qt y ROS2 necesarias target_link_libraries(example2 Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Qml ) # Define las dependencias de ament para ROS2 ament_target_dependencies(example2 rclcpp std_msgs example_interfaces geometry_msgs ) # Configuración de instalación include(GNUInstallDirs) install(TARGETS example2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) # Define el paquete ament ament_package()
And the path are this:
@ROS2-Humble-with-QML
The error are:CMakeLists.txt:24: error: Unknown CMake command "qt_add_qml_module".
the version I used is CMake 3.29.3
Qt 6.7.2 -
My conclusion is don't do this because the cmakes is different in both so try to separete it
-