cmake_minimum_required(VERSION 3.5)
project(practice_scamper)
# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()
# Add compile options
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# Find dependencies
set(ROS_LIBS rclcpp;rclcpp_components;cv_bridge;message_filters)
set(ROS_LIBS ${ROS_LIBS};geometry_msgs;sensor_msgs)
set(ROS_LIBS ${ROS_LIBS};tf2_geometry_msgs;tf2_ros)
set(ROS_LIBS ${ROS_LIBS};std_srvs;ros_dobot_interfaces)
find_package(ament_cmake REQUIRED)
foreach(lib IN LISTS ROS_LIBS)
  find_package(${lib} REQUIRED)
endforeach()
# Set target
add_library(${PROJECT_NAME} SHARED
  src/color_extractor.cpp
  src/color_extractor_viewer.cpp
  src/follow_color.cpp
  src/reconstruct_3d.cpp
  src/grasp_ball.cpp
)
ament_target_dependencies(${PROJECT_NAME} ${ROS_LIBS})
rclcpp_components_register_nodes(${PROJECT_NAME} "practice_scamper::ColorExtractor")
rclcpp_components_register_nodes(${PROJECT_NAME} "practice_scamper::ColorExtractorViewer")
rclcpp_components_register_nodes(${PROJECT_NAME} "practice_scamper::FollowColor")
rclcpp_components_register_nodes(${PROJECT_NAME} "practice_scamper::Reconstruct3D")
rclcpp_components_register_nodes(${PROJECT_NAME} "practice_scamper::GraspBall")
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
install(DIRECTORY cfg DESTINATION share/${PROJECT_NAME})
# Call ament build system
ament_package()