Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake target libraries and linking so plugins work #667

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
21 changes: 8 additions & 13 deletions rotors_gazebo_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Copy link
Member

Choose a reason for hiding this comment

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

Could you not rename the package? This would need to propagate further than just this cmake file.

Copy link
Author

Choose a reason for hiding this comment

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

This doesn't rename a package. It renames the cmake library created for the protobuf msgs

target_link_libraries(mav_proto_msgs ${PROTOBUF_LIBRARY} gazebo_msgs)
list(APPEND targets_to_install mav_proto_msgs)

# ============================================== #
# ==================== CATKIN ================== #
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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})
Expand Down Expand Up @@ -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()
Expand All @@ -423,15 +418,15 @@ 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()
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()
Expand Down