cmake_minimum_required(VERSION 3.10)
project(tf3_geometry_msgs)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Find dependencies
find_package(Boost COMPONENTS thread REQUIRED)
find_package(GTest REQUIRED)
# Finding Eigen3
find_package(Eigen3 REQUIRED)

# Include directories
include_directories(
  include
  ${EIGEN3_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
  ${GTEST_INCLUDE_DIRS}
)

# Install headers
install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION include/${PROJECT_NAME}
)

add_library(tf3_geometry_msgs INTERFACE
)

target_include_directories(tf3_geometry_msgs
    INTERFACE
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:include>
)

# Liên kết với std_msgs nếu bạn có file Header.h trong include/std_msgs/
target_link_libraries(tf3_geometry_msgs INTERFACE 
                      geometry_msgs
                      data_convert
                      )

# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
install(TARGETS tf3_geometry_msgs
  EXPORT tf3_geometry_msgs-targets
  INCLUDES DESTINATION include # Cài đặt include
)

# --- Xuất export set tf3_geometry_msgs-targets thành file CMake module ---
# --- Tạo file lib/cmake/tf3_geometry_msgs/tf3_geometry_msgs-targets.cmake ---
# --- File này chứa cấu hình giúp project khác có thể dùng ---
# --- Find_package(tf3_geometry_msgs REQUIRED) ---
# --- Target_link_libraries(my_app PRIVATE tf3_geometry_msgs::tf3_geometry_msgs) ---
install(EXPORT tf3_geometry_msgs-targets 
  FILE tf3_geometry_msgs-targets.cmake
  DESTINATION lib/cmake/tf3_geometry_msgs
)
  
#   # Test: tomsg_frommsg
  add_executable(test_tomsg_frommsg test/test_tomsg_frommsg.cpp)
  target_link_libraries(test_tomsg_frommsg 
    ${GTEST_LIBRARIES}
    tf3_geometry_msgs
    Threads::Threads
    tf3
    data_convert
  )
#   # Test: tf2_geometry_msgs
  add_executable(test_geometry_msgs test/test_tf2_geometry_msgs.cpp)
  target_link_libraries(test_geometry_msgs 
    ${GTEST_LIBRARIES}
    Threads::Threads
    tf3
    tf3_geometry_msgs
    data_convert
  )
