cmake_minimum_required(VERSION 3.8)
project(g2_2025_odometry_visualization_pkg)

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

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)

# Include directories
include_directories(include)

# Add executable
add_executable(odometry_visualizer
  src/main.cpp
  src/node/OdometryVisualizer.cpp
)

ament_target_dependencies(odometry_visualizer
  rclcpp
  geometry_msgs
  visualization_msgs
  tf2
  tf2_ros
)

# Install executable
install(TARGETS
  odometry_visualizer
  DESTINATION lib/${PROJECT_NAME}
)

# Install launch files
install(DIRECTORY
  launch
  DESTINATION share/${PROJECT_NAME}
)

# Install URDF files
install(DIRECTORY
  urdf
  DESTINATION share/${PROJECT_NAME}
)

# Install RViz config files
install(DIRECTORY
  rviz
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_cmake_gtest REQUIRED)
  find_package(tf2_ros REQUIRED)

  # Add test executable
  ament_add_gtest(test_odometry_visualizer
    test/test_odometry_visualizer.cpp
  )
  
  target_include_directories(test_odometry_visualizer PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
  )
  
  ament_target_dependencies(test_odometry_visualizer
    rclcpp
    geometry_msgs
    visualization_msgs
    tf2
    tf2_ros
  )

  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files

  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files

endif()

ament_package()
