Normally, you would add a system dependency on sdformat, which is released with Hydro. Unfortunately, it does not seem to have been defined via rosdep yet. You should probably contribute the missing definition to fix that problem.
Then, in your package.xml, add:
<build_depend>sdformat</build_depend>
<run_depend>sdformat</run_depend>
With sdformat installed, in your CMakeLists.txt, find the SDF system library:
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDF sdformat REQUIRED)
include_directories(include ${SDF_INCLUDE_DIRS})
Then your own code will need something like this to build with it:
add_executable(your_node ${YOUR_NODE_SOURCES})
target_link_libraries(your_node
${catkin_LIBRARIES}
${SDF_LIBRARIES})
Originally posted by joq with karma: 113 on 2014-01-02
This answer was NOT ACCEPTED on the original site
Post score: 1
Original comments
Comment by scpeters on 2014-01-03:
You actually need to search for sdformat: pkg_check_modules(SDF sdformat REQUIRED)
. It's a quirk of Gazebo's cmake setup; we already had variables with prefix SDF_
spread out, so we search for sdformat, but with variables named SDF. Sorry if that's a confusing example.
Comment by joq on 2014-01-03:
Thanks for the correction. Are the SDF_INCLUDE_DIRS
and SDF_LIBRARIES
variable names I had guessed correct?
Comment by scpeters on 2014-01-06:
Yes, I believe that SDF_INCLUDE_DIRS and SDF_LIBRARIES are correct.