cmake_minimum_required(VERSION 3.8)
project(vehicle_profile_manager)

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

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(calibration_common_interfaces REQUIRED)
find_package(calibration_vehicle_profile_interfaces REQUIRED)

# 共享库（组件形式）：节点可以被 component_container 动态加载
add_library(vehicle_profile_manager_component SHARED
  src/vehicle_profile_manager_node.cpp
)

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

ament_target_dependencies(vehicle_profile_manager_component
  rclcpp
  rclcpp_components
  calibration_common_interfaces
  calibration_vehicle_profile_interfaces
)

rclcpp_components_register_nodes(vehicle_profile_manager_component
  "vehicle_profile_manager::VehicleProfileManagerNode"
)

# 可执行：独立进程启动
add_executable(vehicle_profile_manager_node src/main.cpp)
ament_target_dependencies(vehicle_profile_manager_node
  rclcpp
  rclcpp_components
)
target_link_libraries(vehicle_profile_manager_node
  vehicle_profile_manager_component
)

install(TARGETS
  vehicle_profile_manager_component
  vehicle_profile_manager_node
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/
  DESTINATION include/
)

ament_package()
