From 10409ab7b094425d77875592b2497f9c603f87ed Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Thu, 14 Dec 2023 13:26:49 +0100 Subject: [PATCH] cmake cleanups --- CMakeLists.txt | 8 ++++--- src/CMakeLists.txt | 59 +++++++++++++++++----------------------------- 2 files changed, 26 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 596c8710..8eda4dfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.5) PROJECT(plotjuggler_ros) +find_package(ament_cmake QUIET) +find_package(catkin QUIET) + # http://answers.ros.org/question/230877/optionally-build-a-package-with-catkin/ -if( CATKIN_DEVEL_PREFIX OR catkin_FOUND OR CATKIN_BUILD_BINARY_PACKAGE) +if( catkin_FOUND OR CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE) set(COMPILING_WITH_CATKIN 1) message(STATUS "---------------------------------------------------------------------") @@ -23,14 +26,13 @@ if( CATKIN_DEVEL_PREFIX OR catkin_FOUND OR CATKIN_BUILD_BINARY_PACKAGE) catkin_package( CATKIN_DEPENDS ${ROS_DEPENDENCIES} ) -elseif( DEFINED ENV{AMENT_PREFIX_PATH}) +elseif( ament_cmake_FOUND ) set(COMPILING_WITH_AMENT 1) message(STATUS "---------------------------------------------------------------------") message(STATUS "PlotJuggler is being built using AMENT. ROS2 plugins will be compiled") message(STATUS "---------------------------------------------------------------------") - find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rcpputils REQUIRED) find_package(rosbag2 REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 223942c6..cb52aecf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,3 @@ -# Qt related stuff -set(CMAKE_AUTOMOC ON) -SET(CMAKE_AUTOUIC ON) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - add_definitions(${QT_DEFINITIONS}) add_definitions(-DQT_PLUGIN) add_definitions(-DQT_SHARED) @@ -12,8 +7,7 @@ QT5_WRAP_UI ( COMMON_UI_SRC rule_editing.ui dialog_select_ros_topics.ui dialog_with_itemlist.ui - publisher_select_dialog.ui - ) + publisher_select_dialog.ui ) SET( COMMON_SRC dialog_select_ros_topics.h @@ -21,29 +15,29 @@ SET( COMMON_SRC dialog_with_itemlist.h publisher_select_dialog.h parser_configuration.cpp - parser_configuration.h - ) + parser_configuration.h ) ############# -if(COMPILING_WITH_CATKIN) +include_directories( + ${catkin_INCLUDE_DIRS} + ${plotjuggler_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} ) - include_directories( - ${catkin_INCLUDE_DIRS} - ${plotjuggler_INCLUDE_DIRS} - ) +if(COMPILING_WITH_CATKIN) - list(APPEND COMMON_SRC + add_library( commonROS STATIC + ${COMMON_SRC} + ${COMMON_UI_SRC} qnodedialog.cpp - rule_editing.cpp) + rule_editing.cpp ) - add_library( commonROS STATIC ${COMMON_SRC} ${COMMON_UI_SRC} ) target_compile_definitions(commonROS PUBLIC DISABLE_RULE_EDITING) - target_link_libraries( commonROS PRIVATE + target_link_libraries( commonROS ${Qt5Widgets_LIBRARIES} ${Qt5Xml_LIBRARIES} - ${plotjuggler_LIBRARIES} - ${catkin_LIBRARIES}) + ${catkin_LIBRARIES} + ${plotjuggler_LIBRARIES}) ######### add_library( DataLoadROS SHARED @@ -69,10 +63,6 @@ if(COMPILING_WITH_CATKIN) ####################################################################### elseif(COMPILING_WITH_AMENT) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) - - list( APPEND COMMON_SRC ros_parsers/ros2_parser.cpp ) - set(AMENT_DEPENDENCIES rclcpp rosbag2 @@ -80,17 +70,18 @@ elseif(COMPILING_WITH_AMENT) rosbag2_transport tf2_msgs tf2_ros - plotjuggler - ) + plotjuggler ) - add_library( commonROS STATIC ${COMMON_SRC} ${COMMON_UI_SRC}) + add_library( commonROS STATIC + ${COMMON_SRC} + ${COMMON_UI_SRC} + ros_parsers/ros2_parser.cpp ) target_compile_definitions(commonROS PUBLIC DISABLE_RULE_EDITING) target_link_libraries( commonROS ${Qt5Widgets_LIBRARIES} ${Qt5Xml_LIBRARIES} ${plotjuggler_LIBRARIES}) - ament_target_dependencies( commonROS ${AMENT_DEPENDENCIES}) ############# @@ -113,15 +104,9 @@ elseif(COMPILING_WITH_AMENT) message(STATUS "Detected Humble") target_compile_definitions(TopicPublisherROS2 PUBLIC ROS_HUMBLE) endif() - - add_executable(test_ros2_parser - ros_parsers/test_ros2_parser.cpp - ros_parsers/ros2_parser.cpp) - target_link_libraries( test_ros2_parser commonROS) - ament_target_dependencies( test_ros2_parser ${AMENT_DEPENDENCIES}) - endif() + ####################################################################### if(COMPILING_WITH_CATKIN) @@ -130,11 +115,9 @@ if(COMPILING_WITH_CATKIN) DataStreamROS RosTopicPublisher RosoutPublisher - DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/ - ) + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/ ) elseif(COMPILING_WITH_AMENT) install(TARGETS - test_ros2_parser DataLoadROS2 DataStreamROS2 TopicPublisherROS2