ros
This commit is contained in:
parent
594f0fe49e
commit
d7eed928fb
|
|
@ -1,13 +1,61 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# ========================================================
|
||||
# Dual-mode CMakeLists.txt: Supports both Catkin and Standalone CMake
|
||||
# ========================================================
|
||||
|
||||
# Detect if building with Catkin
|
||||
if(DEFINED CATKIN_DEVEL_PREFIX OR DEFINED CATKIN_TOPLEVEL)
|
||||
set(BUILDING_WITH_CATKIN TRUE)
|
||||
message(STATUS "Building data_convert with Catkin")
|
||||
else()
|
||||
set(BUILDING_WITH_CATKIN FALSE)
|
||||
message(STATUS "Building data_convert with Standalone CMake")
|
||||
endif()
|
||||
|
||||
project(data_convert)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# ========================================================
|
||||
# Find dependencies
|
||||
# ========================================================
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
robot_geometry_msgs
|
||||
)
|
||||
endif()
|
||||
|
||||
# ========================================================
|
||||
# Catkin specific configuration
|
||||
# ========================================================
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
catkin_package(
|
||||
INCLUDE_DIRS include
|
||||
# Header-only library; keep LIBRARIES for visibility when exporting
|
||||
LIBRARIES data_convert
|
||||
CATKIN_DEPENDS robot_geometry_msgs
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(data_convert INTERFACE)
|
||||
|
||||
target_link_libraries(data_convert INTERFACE
|
||||
# Link libraries
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
target_link_libraries(data_convert INTERFACE
|
||||
${catkin_LIBRARIES}
|
||||
)
|
||||
else()
|
||||
target_link_libraries(data_convert INTERFACE
|
||||
robot_geometry_msgs
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BUILDING_WITH_CATKIN)
|
||||
add_dependencies(data_convert ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
|
||||
endif()
|
||||
|
||||
target_include_directories(data_convert
|
||||
INTERFACE
|
||||
|
|
@ -15,12 +63,24 @@ target_include_directories(data_convert
|
|||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
# ========================================================
|
||||
# Installation
|
||||
# ========================================================
|
||||
|
||||
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
||||
install(TARGETS data_convert
|
||||
EXPORT data_convert-targets
|
||||
INCLUDES DESTINATION include # Cài đặt include
|
||||
)
|
||||
|
||||
if(NOT BUILDING_WITH_CATKIN)
|
||||
# Cài đặt headers (standalone)
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
endif()
|
||||
|
||||
# --- Xuất export set data_convert-targets thành file CMake module ---
|
||||
# --- Tạo file lib/cmake/data_convert/data_convert-targets.cmake ---
|
||||
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
||||
|
||||
<build_depend>libconsole-bridge-dev</build_depend>
|
||||
|
||||
<run_depend>libconsole-bridge-dev</run_depend>
|
||||
<build_depend>robot_geometry_msgs</build_depend>
|
||||
<run_depend>robot_geometry_msgs</run_depend>
|
||||
|
||||
</package>
|
||||
Loading…
Reference in New Issue
Block a user