99 lines
2.8 KiB
CMake
Executable File
99 lines
2.8 KiB
CMake
Executable File
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 robot_tf3_sensor_msgs with Catkin")
|
|
find_package(catkin REQUIRED)
|
|
else()
|
|
set(BUILDING_WITH_CATKIN FALSE)
|
|
message(STATUS "Building robot_tf3_sensor_msgs with Standalone CMake")
|
|
endif()
|
|
|
|
project(robot_tf3_sensor_msgs)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
# ========================================================
|
|
# Catkin specific configuration
|
|
# ========================================================
|
|
|
|
if(BUILDING_WITH_CATKIN)
|
|
catkin_package(
|
|
INCLUDE_DIRS include
|
|
# LIBRARIES không cần vì đây là header-only library
|
|
# CATKIN_DEPENDS không cần vì dependencies không phải Catkin packages
|
|
DEPENDS Eigen3 Boost
|
|
)
|
|
endif()
|
|
|
|
# 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}
|
|
)
|
|
|
|
add_library(robot_tf3_sensor_msgs INTERFACE
|
|
)
|
|
|
|
target_include_directories(robot_tf3_sensor_msgs
|
|
INTERFACE
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
)
|
|
|
|
target_link_libraries(robot_tf3_sensor_msgs INTERFACE
|
|
robot_sensor_msgs
|
|
data_convert
|
|
)
|
|
|
|
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
|
install(TARGETS robot_tf3_sensor_msgs
|
|
EXPORT robot_tf3_sensor_msgs-targets
|
|
INCLUDES DESTINATION include # Cài đặt include
|
|
)
|
|
|
|
# --- Xuất export set robot_tf3_sensor_msgs-targets thành file CMake module ---
|
|
# --- Tạo file lib/cmake/robot_tf3_sensor_msgs/robot_tf3_sensor_msgs-targets.cmake ---
|
|
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
|
# --- Find_package(robot_tf3_sensor_msgs REQUIRED) ---
|
|
# --- Target_link_libraries(my_app PRIVATE robot_tf3_sensor_msgs::robot_tf3_sensor_msgs) ---
|
|
install(EXPORT robot_tf3_sensor_msgs-targets
|
|
FILE robot_tf3_sensor_msgs-targets.cmake
|
|
NAMESPACE robot_tf3_sensor_msgs::
|
|
DESTINATION lib/cmake/robot_tf3_sensor_msgs
|
|
)
|
|
|
|
add_executable(test_tf2_sensor_msgs test/test_tf2_sensor_msgs.cpp)
|
|
target_include_directories(test_tf2_sensor_msgs PUBLIC
|
|
${EIGEN3_INCLUDE_DIRS}
|
|
${GTEST_INCLUDE_DIRS}
|
|
robot_tf3_sensor_msgs
|
|
geometry_msgs
|
|
tf3
|
|
)
|
|
target_link_libraries(test_tf2_sensor_msgs
|
|
${GTEST_LIBRARIES}
|
|
Threads::Threads
|
|
robot_tf3_sensor_msgs
|
|
geometry_msgs
|
|
tf3
|
|
data_convert
|
|
)
|