From f0ef762c19e82b571db9626adfbf275d3a74473d Mon Sep 17 00:00:00 2001 From: Jordan Lack Date: Tue, 13 Apr 2021 10:03:02 -0500 Subject: [PATCH 1/3] Fix cmake target libraries and linking so plugins work --- rotors_gazebo_plugins/CMakeLists.txt | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/rotors_gazebo_plugins/CMakeLists.txt b/rotors_gazebo_plugins/CMakeLists.txt index bdf6d8123..28e8063dc 100644 --- a/rotors_gazebo_plugins/CMakeLists.txt +++ b/rotors_gazebo_plugins/CMakeLists.txt @@ -211,13 +211,9 @@ file(GLOB msgs msgs/*.proto) PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${msgs}) # Create a shared library of protobuf messages (.so extension on Linux platforms) -add_library(mav_msgs SHARED ${PROTO_SRCS}) -target_link_libraries(mav_msgs ${PROTOBUF_LIBRARY} gazebo_msgs) - -# This causes mav_msgs to be linked with every created library in this file from this -# point forward. -# NOTE: This is deprecated, should be using target_link_libraries instead -link_libraries(mav_msgs) +add_library(mav_proto_msgs SHARED ${PROTO_SRCS}) +target_link_libraries(mav_proto_msgs ${PROTOBUF_LIBRARY} gazebo_msgs) +list(APPEND targets_to_install mav_proto_msgs) # ============================================== # # ==================== CATKIN ================== # @@ -228,7 +224,7 @@ if (NOT NO_ROS) if(${gazebo_dev_FOUND}) catkin_package( INCLUDE_DIRS include ${Eigen_INCLUDE_DIRS} - LIBRARIES rotors_gazebo_motor_model rotors_gazebo_controller_interface + LIBRARIES rotors_gazebo_motor_model rotors_gazebo_controller_interface mav_proto_msgs CATKIN_DEPENDS cv_bridge geometry_msgs mav_msgs octomap_msgs octomap_ros rosbag roscpp gazebo_plugins rotors_comm rotors_control std_srvs tf DEPENDS Eigen octomap OpenCV #CFG_EXTRAS rotors_gazebo_plugins.cmake @@ -237,7 +233,7 @@ if (NOT NO_ROS) else() catkin_package( INCLUDE_DIRS include ${Eigen_INCLUDE_DIRS} - LIBRARIES rotors_gazebo_motor_model rotors_gazebo_controller_interface + LIBRARIES rotors_gazebo_motor_model rotors_gazebo_controller_interface mav_proto_msgs CATKIN_DEPENDS cv_bridge geometry_msgs mav_msgs octomap_msgs octomap_ros rosbag roscpp gazebo_plugins rotors_comm rotors_control std_srvs tf DEPENDS Eigen octomap OpenCV #CFG_EXTRAS rotors_gazebo_plugins.cmake @@ -246,7 +242,6 @@ if (NOT NO_ROS) endif() endif() - # Including GAZEBO_MSG_INCLUDE_DIRS here allows the .cpp files generated by custom .proto files to find # the .cpp/hpp files generated by the built-in Gazebo .proto files include_directories(include ${catkin_INCLUDE_DIRS} ${GAZEBO_MSG_INCLUDE_DIRS}) @@ -413,7 +408,7 @@ if (BUILD_MAVLINK_INTERFACE_PLUGIN) message(WARN "Mavlink headers found and mavros version check successful, building MavlinkInterfacePlugin") # Note that this library includes TWO .cpp files. add_library(rotors_gazebo_mavlink_interface SHARED src/gazebo_mavlink_interface.cpp src/geo_mag_declination.cpp) - target_link_libraries(rotors_gazebo_mavlink_interface ${target_linking_LIBRARIES} ${mav_msgs}) + target_link_libraries(rotors_gazebo_mavlink_interface ${target_linking_LIBRARIES} mav_proto_msgs) add_dependencies(rotors_gazebo_mavlink_interface ${catkin_EXPORTED_TARGETS} ${mavros_EXPORTED_TARGETS} ${mavros_msgs_EXPORTED_TARGETS}) list(APPEND targets_to_install rotors_gazebo_mavlink_interface) endif() @@ -423,7 +418,7 @@ endif() #==================================== MOTOR MODEL PLUGIN ========================================// add_library(rotors_gazebo_motor_model SHARED src/gazebo_motor_model.cpp) -target_link_libraries(rotors_gazebo_motor_model ${target_linking_LIBRARIES} ) +target_link_libraries(rotors_gazebo_motor_model ${target_linking_LIBRARIES} mav_proto_msgs) if (NOT NO_ROS) add_dependencies(rotors_gazebo_motor_model ${catkin_EXPORTED_TARGETS}) endif() @@ -431,7 +426,7 @@ list(APPEND targets_to_install rotors_gazebo_motor_model) #==================================== MULTIROTOR BASE PLUGIN ====================================// add_library(rotors_gazebo_multirotor_base_plugin SHARED src/gazebo_multirotor_base_plugin.cpp) -target_link_libraries(rotors_gazebo_multirotor_base_plugin ${target_linking_LIBRARIES} ) +target_link_libraries(rotors_gazebo_multirotor_base_plugin ${target_linking_LIBRARIES} mav_proto_msgs) if (NOT NO_ROS) add_dependencies(rotors_gazebo_multirotor_base_plugin ${catkin_EXPORTED_TARGETS}) endif() From 89a926df993414d33f49cc44ea3e358bb5db3391 Mon Sep 17 00:00:00 2001 From: Jordan Lack Date: Wed, 14 Apr 2021 15:27:54 -0500 Subject: [PATCH 2/3] Add linking of mav_proto_msgs to gazebo_ros_interface plugin as I missed it in prev commit --- rotors_gazebo_plugins/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rotors_gazebo_plugins/CMakeLists.txt b/rotors_gazebo_plugins/CMakeLists.txt index 28e8063dc..25d06e355 100644 --- a/rotors_gazebo_plugins/CMakeLists.txt +++ b/rotors_gazebo_plugins/CMakeLists.txt @@ -495,7 +495,7 @@ list(APPEND targets_to_install rotors_gazebo_pressure_plugin) # This entire plugin is only built if ROS is a dependency if (NOT NO_ROS) add_library(rotors_gazebo_ros_interface_plugin SHARED src/gazebo_ros_interface_plugin.cpp) - target_link_libraries(rotors_gazebo_ros_interface_plugin ${target_linking_LIBRARIES} ) + target_link_libraries(rotors_gazebo_ros_interface_plugin ${target_linking_LIBRARIES} mav_proto_msgs) add_dependencies(rotors_gazebo_ros_interface_plugin ${catkin_EXPORTED_TARGETS}) list(APPEND targets_to_install rotors_gazebo_ros_interface_plugin) endif() From 9d0e1028ee4040c62b6bdcab89a148ce997ad787 Mon Sep 17 00:00:00 2001 From: Jordan Lack Date: Thu, 22 Apr 2021 09:51:23 -0500 Subject: [PATCH 3/3] Forgot to add the mav_proto_msgs to the list of installed targets --- rotors_gazebo_plugins/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/rotors_gazebo_plugins/CMakeLists.txt b/rotors_gazebo_plugins/CMakeLists.txt index fc6a25f49..b4974a592 100644 --- a/rotors_gazebo_plugins/CMakeLists.txt +++ b/rotors_gazebo_plugins/CMakeLists.txt @@ -213,6 +213,7 @@ PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${msgs}) # Create a shared library of protobuf messages (.so extension on Linux platforms) add_library(mav_proto_msgs SHARED ${PROTO_SRCS}) target_link_libraries(mav_proto_msgs ${PROTOBUF_LIBRARY} gazebo_msgs) +list(APPEND targets_to_install mav_proto_msgs) # ============================================== # # ==================== CATKIN ================== #