cmake_minimum_required(VERSION 3.10)

# Tên dự án
project(mkt_msgs VERSION 1.0.0 LANGUAGES CXX)

# Chuẩn C++
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Cho phép các project khác include được header của mkt_msgs
set(mkt_msgs_INCLUDE_DIRS
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    PARENT_SCOPE
)

include_directories(
        ${PROJECT_SOURCE_DIR}/include
)

# Tạo INTERFACE library (header-only)
add_library(mkt_msgs INTERFACE)
target_link_libraries(mkt_msgs INTERFACE robot_nav_2d_msgs geometry_msgs)

# Set include directories
target_include_directories(mkt_msgs
    INTERFACE 
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:include>
)

# Cài đặt header files
install(DIRECTORY include/mkt_msgs 
        DESTINATION include
        FILES_MATCHING PATTERN "*.h")

install(TARGETS mkt_msgs 
        EXPORT mkt_msgs-targets
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib
        RUNTIME DESTINATION bin)

# Export targets
install(EXPORT mkt_msgs-targets
         FILE mkt_msgs-targets.cmake
        DESTINATION lib/cmake/mkt_msgs)

# In thông tin cấu hình
message(STATUS "=================================")
message(STATUS "Project: ${PROJECT_NAME} (Header-Only)")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "Headers found:")
foreach(hdr ${HEADERS})
    message(STATUS "  - ${hdr}")
endforeach()
message(STATUS "=================================")