cmake_minimum_required(VERSION 3.8)
project(agv_pro_hardware)

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(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(agv_pro_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)

add_library(agv_pro_hardware SHARED
  src/agv_pro_hardware_interface.cpp
)

target_include_directories(agv_pro_hardware PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)

target_compile_features(agv_pro_hardware PUBLIC c_std_99 cxx_std_17)

ament_target_dependencies(agv_pro_hardware
  rclcpp
  hardware_interface
  pluginlib
  sensor_msgs
  std_msgs
  agv_pro_msgs
  tf2
)

target_link_libraries(agv_pro_hardware Boost::system)

pluginlib_export_plugin_description_file(hardware_interface agv_pro_hardware.xml)

install(
  DIRECTORY include/
  DESTINATION include
)

install(
  TARGETS agv_pro_hardware
  EXPORT export_${PROJECT_NAME}
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_dependencies(
  rclcpp
  hardware_interface
  pluginlib
  sensor_msgs
  std_msgs
  agv_pro_msgs
  tf2
)

ament_package()
