67 lines
2.2 KiB
CMake
67 lines
2.2 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
project(robot_std_msgs)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# ========================================================
|
|
# Catkin specific configuration
|
|
# ========================================================
|
|
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
|
set(BUILDING_WITH_CATKIN TRUE)
|
|
message(STATUS "Building robot_std_msgs with Catkin")
|
|
else()
|
|
set(BUILDING_WITH_CATKIN FALSE)
|
|
message(STATUS "Building robot_std_msgs with Standalone CMake")
|
|
endif()
|
|
|
|
if(BUILDING_WITH_CATKIN)
|
|
find_package(catkin REQUIRED COMPONENTS robot_time)
|
|
|
|
## The catkin_package macro generates cmake config files for your package
|
|
## Note: Dependencies (robot_time, etc.) are not Catkin packages,
|
|
## they are built as CMake targets in the same workspace and will be available
|
|
## when this package is built. They are linked via target_link_libraries instead of CATKIN_DEPENDS
|
|
catkin_package(
|
|
INCLUDE_DIRS include
|
|
LIBRARIES robot_std_msgs
|
|
CATKIN_DEPENDS robot_time
|
|
)
|
|
endif()
|
|
|
|
add_library(robot_std_msgs INTERFACE)
|
|
|
|
target_include_directories(robot_std_msgs
|
|
INTERFACE
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
)
|
|
|
|
target_link_libraries(robot_std_msgs INTERFACE robot_time)
|
|
|
|
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
|
# Export target trong mọi trường hợp để các target khác có thể export và phụ thuộc vào nó
|
|
install(TARGETS robot_std_msgs
|
|
EXPORT robot_std_msgs-targets
|
|
INCLUDES DESTINATION include # Cài đặt include
|
|
)
|
|
|
|
if(NOT BUILDING_WITH_CATKIN)
|
|
# Install headers for standalone mode
|
|
install(DIRECTORY include/
|
|
DESTINATION include
|
|
FILES_MATCHING PATTERN "*.h"
|
|
)
|
|
endif()
|
|
|
|
# --- Xuất export set robot_std_msgs-targets thành file CMake module ---
|
|
# --- Tạo file lib/cmake/robot_std_msgs/robot_std_msgs-targets.cmake ---
|
|
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
|
# --- Find_package(robot_std_msgs REQUIRED) ---
|
|
# --- Target_link_libraries(my_app PRIVATE robot_std_msgs::robot_std_msgs) ---
|
|
install(EXPORT robot_std_msgs-targets
|
|
FILE robot_std_msgs-targets.cmake
|
|
NAMESPACE robot_std_msgs::
|
|
DESTINATION lib/cmake/robot_std_msgs
|
|
)
|