cmake_minimum_required(VERSION 3.22)
project(moveit_chomp_optimizer_adapter LANGUAGES CXX)

# Common cmake code applied to all moveit packages
find_package(moveit_common REQUIRED)
moveit_package()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(chomp_motion_planner REQUIRED)
find_package(moveit_core REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rsl REQUIRED)

set(THIS_PACKAGE_INCLUDE_DEPENDS
  chomp_motion_planner
  moveit_core
  pluginlib
  rclcpp
  rsl
)

add_library(moveit_chomp_optimizer_adapter SHARED src/chomp_optimizer_adapter.cpp)
set_target_properties(moveit_chomp_optimizer_adapter PROPERTIES VERSION "${moveit_chomp_optimizer_adapter_VERSION}")
ament_target_dependencies(moveit_chomp_optimizer_adapter ${THIS_PACKAGE_INCLUDE_DEPENDS})

install(
  TARGETS moveit_chomp_optimizer_adapter
  EXPORT moveit_chomp_optimizer_adapterTargets
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
  RUNTIME DESTINATION bin
)

ament_export_targets(moveit_chomp_optimizer_adapterTargets HAS_LIBRARY_TARGET)

pluginlib_export_plugin_description_file(moveit_core chomp_optimizer_adapter_plugin_description.xml)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)

  # These don't pass yet, disable them for now
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  set(ament_cmake_flake8_FOUND TRUE)
  set(ament_cmake_uncrustify_FOUND TRUE)
  set(ament_cmake_lint_cmake_FOUND TRUE)

  # Run all lint tests in package.xml except those listed above
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
