cmake_minimum_required(VERSION 3.8)
project(agv_calib_core)

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(rclcpp_action REQUIRED)
find_package(rclcpp_components REQUIRED) # 🚨 核心依赖：寻找组件库
find_package(behaviortree_cpp_v3 REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(win_ubuntu_bridge REQUIRED)

# 1. 编译大脑为动态链接库 (SHARED) 组件
add_library(brain_node SHARED src/brain_node.cpp) 

# 2. 将 include 暴露给编译器
target_include_directories(brain_node PUBLIC 
    "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
)

ament_target_dependencies(brain_node 
  rclcpp 
  rclcpp_action 
  rclcpp_components
  behaviortree_cpp_v3 
  ament_index_cpp 
  win_ubuntu_bridge
)

# 3. 注册插件
rclcpp_components_register_node(brain_node
  PLUGIN "agv_calib_core::BrainNode"
  EXECUTABLE brain_node_exe 
)

# 4. 安装工程中所有的核心文件夹 (不可遗漏！)
install(TARGETS brain_node brain_node_exe
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/ DESTINATION include)
install(DIRECTORY config/ DESTINATION share/${PROJECT_NAME}/config)
install(DIRECTORY launch/ DESTINATION share/${PROJECT_NAME}/launch)
install(DIRECTORY behavior_trees/ DESTINATION share/${PROJECT_NAME}/behavior_trees)

ament_package()