Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.20)
project(rviz_visual_tools)

# Default to C++14
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down Expand Up @@ -40,7 +40,21 @@ find_package(rviz_common REQUIRED)
find_package(rviz_rendering REQUIRED)
find_package(rviz_default_plugins REQUIRED)

find_package(Qt5 REQUIRED COMPONENTS Widgets)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Test Widgets)

if(Qt${QT_VERSION_MAJOR} STREQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets Core5Compat)
else()#Qt5
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets)
if(${QT_VERSION} VERSION_LESS 5.15.0)
function(qt_wrap_cpp out)
qt5_wrap_cpp(_sources ${ARGN})
set("${out}" ${_sources} PARENT_SCOPE)
endfunction()
endif()
endif()
Comment on lines 44 to 56
Copy link
Member

@nbbrooks nbbrooks Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
find_package(QT NAMES Qt6 Qt5 COMPONENTS Test Widgets)
if(Qt${QT_VERSION_MAJOR} STREQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets Core5Compat)
if(${QT_VERSION} VERSION_LESS 5.15.0)
function(qt_wrap_cpp out)
qt5_wrap_cpp(_sources ${ARGN})
set("${out}" ${_sources} PARENT_SCOPE)
endfunction()
endif()
else()#Qt5
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets)
endif()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
if(${QT_VERSION} VERSION_LESS 5.15.0)
function(qt_wrap_cpp out)
qt5_wrap_cpp(_sources ${ARGN})
set("${out}" ${_sources} PARENT_SCOPE)
endfunction()
endif()
if(Qt${QT_VERSION_MAJOR} STREQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core5Compat)
endif()

CI problem might be here. if(${QT_VERSION} VERSION_LESS 5.15.0) is inside the if(Qt${QT_VERSION_MAJOR} STREQUAL "6") block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the explicit check might just move the failure to find_package time, as we have nothing in package.xml to selectively install stuff like libqt6-core and libqt6core5compat6-dev

I don't know enough about qt5 and qt6 support to know what should get changed there though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind about the explciit check, I do see it is in find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets Core5Compat) already

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it is inside the incorrect if(Qt${QT_VERSION_MAJOR} STREQUAL "6") syntax. OK let's see what my suggested change does. Prob move the error to find_package time. And then we may need to figure out how to support selective package.xml dependencies based on ROS version (a topic that came up in the December community meeting)



## Qt5 boilerplate options from http://doc.qt.io/qt-5/cmake-manual.html
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand Down Expand Up @@ -83,8 +97,12 @@ target_link_libraries(${PROJECT_NAME}_gui PUBLIC
rviz_rendering::rviz_rendering
rviz_default_plugins::rviz_default_plugins
rviz_ogre_vendor::OgreMain
Qt5::Widgets
)
if(Qt${QT_VERSION_MAJOR} STREQUAL "6")
target_link_libraries(${PROJECT_NAME}_gui PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core5Compat ${PROJECT_NAME}_remote_control)
elseif()
target_link_libraries(${PROJECT_NAME}_gui PUBLIC Qt${QT_VERSION_MAJOR}::Widgets ${PROJECT_NAME}_remote_control)
endif()

# prevent pluginlib from using boost
target_compile_definitions(${PROJECT_NAME}_gui PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
Expand Down Expand Up @@ -118,20 +136,32 @@ add_library(${PROJECT_NAME} SHARED
src/tf_visual_tools.cpp
)
target_compile_definitions(${PROJECT_NAME} PRIVATE _USE_MATH_DEFINES)
target_link_libraries(${PROJECT_NAME}

set(${PROJECT_NAME}_LINK_LIBRARIES
${PROJECT_NAME}_remote_control
Eigen3::Eigen
rclcpp::rclcpp
rclcpp_components::component
${visualization_msgs_TARGETS}
tf2::tf2
tf2_eigen::tf2_eigen
${tf2_geometry_msgs_TARGETS}
${sensor_msgs_TARGETS}
${shape_msgs_TARGETS}
${std_msgs_TARGETS}
${trajectory_msgs_TARGETS}
${visualization_msgs_TARGETS}
eigen_stl_containers::eigen_stl_containers
rclcpp::rclcpp
rclcpp_components::component
rclcpp_components::component_manager
sensor_msgs::sensor_msgs_library
tf2::tf2
tf2_eigen::tf2_eigen
tf2_geometry_msgs::tf2_geometry_msgs
)

if(QT_VERSION_MAJOR STREQUAL "6")
list(APPEND ${PROJECT_NAME}_LINK_LIBRARIES
Qt6::Core5Compat
)
endif()

target_link_libraries(${PROJECT_NAME}
${${PROJECT_NAME}_LINK_LIBRARIES}
)

# Library
Expand All @@ -157,6 +187,7 @@ add_executable(${PROJECT_NAME}_demo
target_compile_definitions(${PROJECT_NAME}_demo PRIVATE _USE_MATH_DEFINES)
target_link_libraries(${PROJECT_NAME}_demo
${PROJECT_NAME}
${PROJECT_NAME}_remote_control
rclcpp::rclcpp
${geometry_msgs_TARGETS}
${std_msgs_TARGETS}
Expand All @@ -167,6 +198,7 @@ add_executable(${PROJECT_NAME}_imarker_simple_demo
src/imarker_simple_demo.cpp)
target_compile_definitions(${PROJECT_NAME}_imarker_simple_demo PRIVATE _USE_MATH_DEFINES)
target_link_libraries(${PROJECT_NAME}_imarker_simple_demo
${PROJECT_NAME}_remote_control
${PROJECT_NAME}_imarker_simple
rclcpp::rclcpp
)
Expand Down Expand Up @@ -242,6 +274,7 @@ if (BUILD_TESTING)
target_compile_definitions(${PROJECT_NAME}_rvt_test PRIVATE _USE_MATH_DEFINES)
target_link_libraries(${PROJECT_NAME}_rvt_test
${PROJECT_NAME}
${PROJECT_NAME}_remote_control
rclcpp::rclcpp
)
endif()
Expand Down
2 changes: 1 addition & 1 deletion include/rviz_visual_tools/tf_visual_tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// Eigen
#include <Eigen/Geometry>

#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/transform_broadcaster.hpp>

namespace rviz_visual_tools
{
Expand Down
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
<depend>std_msgs</depend>
<depend>trajectory_msgs</depend>

<build_depend>qtbase5-dev</build_depend>
<build_depend>qt6-base-dev</build_depend>
<build_depend>eigen</build_depend>

<build_export_depend>eigen</build_export_depend>
<exec_depend>libqt5-widgets</exec_depend>
<exec_depend>libqt6widgets6t64</exec_depend>

<!-- Launch files -->
<exec_depend>ament_index_python</exec_depend>
Expand Down
Loading