cmake_minimum_required(VERSION 3.8)
project(toid_spinner_controller)

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

set(library_name toid_spinner_controller)


set(PACKAGE_DEPS
  rclcpp
  geometry_msgs
  nav2_costmap_2d
  pluginlib
  nav_msgs
  nav2_util
  nav2_core
  tf2
  tf2_ros
  angles
  nav2_controller
)

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

add_library(${library_name} SHARED
        src/toid_spinner_controller.cpp
        src/path_handler.cpp)

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/
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

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

pluginlib_export_plugin_description_file(nav2_core toid_spinner_controller.xml)

ament_package()
