cmake_minimum_required(VERSION 3.8)
project(toid_costmaps)

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

set(library_name toid_costmaps)

set(
  PACKAGE_DEPS
  rclcpp
  ament_index_cpp
  Boost
  geometry_msgs
  pluginlib
  nav_msgs
  nav2_core
  nav2_costmap_2d
  nav2_util
  tf2
  tf2_geometry_msgs
  tf2_ros
  Eigen3
  toid_msgs
)

set(
  SOURCES
  src/game_elements_layer.cpp
  src/rival_layer.cpp
)

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

find_package(Boost REQUIRED COMPONENTS json)


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

target_link_libraries(
  ${library_name}
  Boost::json
)

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

install(
  DIRECTORY elements
  DESTINATION share/${PROJECT_NAME}/
)

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

pluginlib_export_plugin_description_file(nav2_costmap_2d toid_costmaps.xml)

ament_package()
