cmake_minimum_required(VERSION 3.8)
project(toid_behaviors)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(library_name toid_behaviors)

set(
  PACKAGE_DEPS

  rclcpp
  angles
  geometry_msgs
  pluginlib
  nav_msgs
  nav2_core
  nav2_behaviors
  nav2_costmap_2d
  nav2_util
  tf2
  tf2_geometry_msgs
  tf2_ros
  toid_msgs
)

set(
  SOURCES
  src/scl.cpp
  src/move_coords.cpp
  src/simple_move.cpp
  src/simple_rotate.cpp
  src/simple_translate_x.cpp
  src/approach_acorns.cpp
  src/rotate_acorns.cpp
)

find_package(ament_cmake REQUIRED)
foreach(PACKAGE ${PACKAGE_DEPS})
  find_package(${PACKAGE} REQUIRED)
endforeach()

add_library(${library_name} SHARED ${SOURCES})

target_include_directories(
  ${library_name} 
  PRIVATE 

  include
)

ament_target_dependencies(
  ${library_name}
  ${PACKAGE_DEPS}
)

install(TARGETS ${library_name}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin 
)

install(
  DIRECTORY include/
  DESTINATION include/
)

ament_export_include_directories(include)
ament_export_libraries(${library_name})
ament_export_dependencies(${PACKAGE_DEPS})

pluginlib_export_plugin_description_file(nav2_core toid_behaviors.xml)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
