CMakeLists

cmake_minimum_required(VERSION 2.8.3)

project(bridge)

if(NOT WIN32)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
endif()
set(CMAKE_BUILD_TYPE DEBUG)

find_package(rmw REQUIRED)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)
find_package(std_msgs REQUIRED)

# find ROS 1 packages
include(cmake/find_ros1_package.cmake)

find_package(PkgConfig)
if(NOT PKG_CONFIG_FOUND)
  message(STATUS "Failed to find PkgConfig, skipping...")
  # call ament_package() to avoid being treated as a plain CMake package from ament_tools
  ament_package()
  return()
endif()

find_ros1_package(roscpp)
if(NOT ros1_roscpp_FOUND)
  message(STATUS "Failed to find ROS 1 roscpp, skipping...")
  # call ament_package() to avoid being treated as a plain CMake package from ament_tools
  ament_package()
  return()
endif()

find_ros1_package(sensor_msgs REQUIRED)
find_ros1_package(std_msgs REQUIRED)

ament_export_include_directories(include)

ament_package()

include_directories(include)

function(custom_executable target)
  cmake_parse_arguments(
    ARG "ROS1_DEPENDENCIES" "" "TARGET_DEPENDENCIES" ${ARGN})

  add_executable(${target}${target_suffix}
    ${ARG_UNPARSED_ARGUMENTS})
  ament_target_dependencies(${target}${target_suffix}
    ${ARG_TARGET_DEPENDENCIES}
    "rclcpp${target_suffix}")
  if(ARG_ROS1_DEPENDENCIES)
    ament_target_dependencies(${target}${target_suffix}
      "ros1_roscpp"
      "ros1_hros_actuation_msgs")
  endif()
  if(ARG_DEPENDENCIES)
    add_dependencies(${target}${target_suffix} ${ARG_DEPENDENCIES})
  endif()

  install(TARGETS ${target}${target_suffix}
    DESTINATION bin)
endfunction()

custom_executable(bridge_1_to_2 "src/bridge_1_to_2.cpp"
    ROS1_DEPENDENCIES
    TARGET_DEPENDENCIES "std_msgs")

custom_executable(bridge_2_to_1 "src/bridge_2_to_1.cpp"
    ROS1_DEPENDENCIES
    TARGET_DEPENDENCIES "std_msgs")