cmake_minimum_required(VERSION 3.10)
project(std_msgs)

set(CMAKE_CXX_STANDARD 17)

add_library(std_msgs INTERFACE)

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

target_link_libraries(std_msgs INTERFACE robot_time)

# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
install(TARGETS std_msgs
  EXPORT std_msgs-targets
  ARCHIVE DESTINATION lib      # Thư viện tĩnh .a
  LIBRARY DESTINATION lib      # Thư viện động .so
  RUNTIME DESTINATION bin      # File thực thi (nếu có)
  INCLUDES DESTINATION include # Cài đặt include
)

# --- Xuất export set std_msgs-targets thành file CMake module ---
# --- Tạo file lib/cmake/std_msgs/std_msgs-targets.cmake ---
# --- File này chứa cấu hình giúp project khác có thể dùng ---
# --- Find_package(std_msgs REQUIRED) ---
# --- Target_link_libraries(my_app PRIVATE std_msgs::std_msgs) ---
install(EXPORT std_msgs-targets 
  FILE std_msgs-targets.cmake
  NAMESPACE std_msgs::
  DESTINATION lib/cmake/std_msgs
)
