cmake_minimum_required(VERSION 3.20)
project(easynav_vff_controller)

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

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(easynav_core REQUIRED)
find_package(easynav_common REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(PCL REQUIRED COMPONENTS common io)
find_package(pluginlib REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(tf2 REQUIRED)

set(dependencies
  rclcpp
  rclcpp_lifecycle
  easynav_core
  easynav_common
  pluginlib
  visualization_msgs
  tf2
)

add_library(vff_controller SHARED
  src/easynav_vff_controller/VffController.cpp
)
target_include_directories(vff_controller PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  ${PCL_INCLUDE_DIRS}
)
target_link_libraries(vff_controller
  easynav_core::easynav_core
  easynav_common::easynav_common
  pluginlib::pluginlib
  ${nav_msgs_TARGETS}
  ${visualization_msgs_TARGETS}
  ${PCL_LIBRARIES}
)

install(DIRECTORY include/
  DESTINATION include/
)

install(TARGETS
  vff_controller
  EXPORT export_${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION lib/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  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(
  vff_controller
)
ament_export_targets(
  export_${PROJECT_NAME}
)
# Register the control plugins
pluginlib_export_plugin_description_file(easynav_core easynav_vff_controller_plugins.xml)
ament_export_dependencies(${dependencies})
ament_package()
