ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I have an example here: https://github.com/lucasw/sdl2_ros/blob/master/CMakeLists.txt

The two problems I encountered (only trying the mixer library) were that newer versions of CMake don't like spaces at the end of lists of libraries and that SDL2_mixer doesn't have a cmake file to find it, though SDL2 itself does:

find_package(SDL2 REQUIRED)
# https://stackoverflow.com/questions/45730098/cmake-leading-or-trailing-whitespace-policy-cmp0004
string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES)
# No FindSDL2_mixer.cmake in Ubuntu 16.04?
# find_package(SDL2_mixer REQUIRED)
# Use pkg-config instead
find_package(PkgConfig)
# Using an underscore like SDL2_mixer doesn't work
pkg_check_modules(SDL2mixer REQUIRED SDL2_mixer)

include_directories(
  ${SDL2_INCLUDE_DIRS}
  ${SDL2mixer_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

add_executable(sdl2_mixer src/sdl2_mixer.cpp)

target_link_libraries(sdl2_mixer
  ${SDL2_LIBRARIES}
  ${SDL2mixer_LIBRARIES}
  ${catkin_LIBRARIES}
)

I have an example here: https://github.com/lucasw/sdl2_ros/blob/master/CMakeLists.txthttps://github.com/lucasw/sdl2_ros/blob/master/CMakeLists.txt There is very little ros in it other than using cmake within catkin and ros params and info messages.

The two problems I encountered (only trying the mixer library) were that newer versions of CMake don't like spaces at the end of lists of libraries and that SDL2_mixer doesn't have a cmake file to find it, though SDL2 itself does:

find_package(SDL2 REQUIRED)
# https://stackoverflow.com/questions/45730098/cmake-leading-or-trailing-whitespace-policy-cmp0004
string(STRIP ${SDL2_LIBRARIES} SDL2_LIBRARIES)
# No FindSDL2_mixer.cmake in Ubuntu 16.04?
# find_package(SDL2_mixer REQUIRED)
# Use pkg-config instead
find_package(PkgConfig)
# Using an underscore like SDL2_mixer doesn't work
pkg_check_modules(SDL2mixer REQUIRED SDL2_mixer)

include_directories(
  ${SDL2_INCLUDE_DIRS}
  ${SDL2mixer_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

add_executable(sdl2_mixer src/sdl2_mixer.cpp)

target_link_libraries(sdl2_mixer
  ${SDL2_LIBRARIES}
  ${SDL2mixer_LIBRARIES}
  ${catkin_LIBRARIES}
)