|
| 1 | +cmake_minimum_required(VERSION 3.8) |
| 2 | +project(elevation_mapping_cupy) |
| 3 | + |
| 4 | +# # Enable C++11 (or higher if needed for ROS 2 and pybind11) |
| 5 | +# set(CMAKE_CXX_STANDARD 11) |
| 6 | +# set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 7 | + |
| 8 | +# Compiler options |
| 9 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 10 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 11 | +endif() |
| 12 | +# Additional dependencies |
| 13 | +# find_package(Python COMPONENTS Interpreter Development) |
| 14 | +find_package(PythonInterp 3 REQUIRED) |
| 15 | +find_package(pybind11 CONFIG REQUIRED) |
| 16 | +find_package(Eigen3 REQUIRED) |
| 17 | +find_package(OpenCV REQUIRED) |
| 18 | + |
| 19 | +# Find pybind11 |
| 20 | + |
| 21 | +message([MAIN] "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") |
| 22 | +message([MAIN] "pybind11_INCLUDE_DIRS = ${pybind11_INCLUDE_DIRS}") |
| 23 | +message([MAIN] "pybind11_LIBRARIES = ${pybind11_LIBRARIES}") |
| 24 | + |
| 25 | +# Find ROS 2 dependencies |
| 26 | +find_package(message_filters REQUIRED) |
| 27 | +find_package(ament_cmake REQUIRED) |
| 28 | +find_package(rclcpp REQUIRED) |
| 29 | +find_package(rclpy REQUIRED) |
| 30 | +find_package(builtin_interfaces REQUIRED) |
| 31 | +find_package(std_msgs REQUIRED) |
| 32 | +find_package(std_srvs REQUIRED) |
| 33 | +find_package(sensor_msgs REQUIRED) |
| 34 | +find_package(grid_map_msgs REQUIRED) |
| 35 | +find_package(geometry_msgs REQUIRED) |
| 36 | +find_package(elevation_map_msgs REQUIRED) |
| 37 | +find_package(grid_map_ros REQUIRED) |
| 38 | +find_package(image_transport REQUIRED) |
| 39 | +find_package(pcl_ros REQUIRED) |
| 40 | +find_package(tf2_eigen REQUIRED) |
| 41 | +find_package(ament_cmake_python REQUIRED) |
| 42 | +find_package(python_cmake_module REQUIRED) |
| 43 | +find_package(point_cloud_transport REQUIRED) |
| 44 | + |
| 45 | +_ament_cmake_python_register_environment_hook() |
| 46 | +ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR script/${PROJECT_NAME}) |
| 47 | + |
| 48 | +# List dependencies for ament_target_dependencies |
| 49 | +set(dependencies |
| 50 | + rclcpp |
| 51 | + rclpy |
| 52 | + std_msgs |
| 53 | + std_srvs |
| 54 | + builtin_interfaces |
| 55 | + geometry_msgs |
| 56 | + sensor_msgs |
| 57 | + elevation_map_msgs |
| 58 | + grid_map_msgs |
| 59 | + grid_map_ros |
| 60 | + image_transport |
| 61 | + pcl_ros |
| 62 | + message_filters |
| 63 | + tf2_eigen |
| 64 | + point_cloud_transport |
| 65 | +) |
| 66 | + |
| 67 | +# Include directories |
| 68 | +include_directories( |
| 69 | + include |
| 70 | + ${PYTHON_INCLUDE_DIRS} |
| 71 | + ${Eigen3_INCLUDE_DIRS} |
| 72 | + ${OpenCV_INCLUDE_DIRS} |
| 73 | + ${pybind11_INCLUDE_DIRS} |
| 74 | + ${elevation_map_msgs_INCLUDE_DIRS} |
| 75 | +) |
| 76 | + |
| 77 | +# Declare C++ library |
| 78 | +add_library(elevation_mapping_ros |
| 79 | + src/elevation_mapping_wrapper.cpp |
| 80 | + src/elevation_mapping_ros.cpp |
| 81 | +) |
| 82 | + |
| 83 | +# Link the library with necessary dependencies |
| 84 | +target_link_libraries(elevation_mapping_ros ${PYTHON_LIBRARIES} ${OpenCV_LIBRARIES} pybind11::embed) |
| 85 | +ament_target_dependencies(elevation_mapping_ros ${dependencies}) |
| 86 | + |
| 87 | +# Declare C++ executable |
| 88 | +add_executable(elevation_mapping_node src/elevation_mapping_node.cpp) |
| 89 | + |
| 90 | +# Link the executable with the library and dependencies |
| 91 | +target_link_libraries(elevation_mapping_node elevation_mapping_ros ${OpenCV_LIBRARIES} pybind11::embed) |
| 92 | +ament_target_dependencies(elevation_mapping_node ${dependencies}) |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +# Install targets |
| 97 | +install( |
| 98 | + TARGETS elevation_mapping_node |
| 99 | + DESTINATION lib/${PROJECT_NAME} |
| 100 | + ARCHIVE DESTINATION lib |
| 101 | + LIBRARY DESTINATION lib |
| 102 | + RUNTIME DESTINATION bin |
| 103 | +) |
| 104 | + |
| 105 | + |
| 106 | +install(TARGETS |
| 107 | + elevation_mapping_node |
| 108 | + DESTINATION lib/${PROJECT_NAME} |
| 109 | +) |
| 110 | + |
| 111 | + |
| 112 | +install( |
| 113 | + TARGETS elevation_mapping_ros |
| 114 | + DESTINATION lib/${PROJECT_NAME} |
| 115 | + ARCHIVE DESTINATION lib |
| 116 | + LIBRARY DESTINATION lib |
| 117 | + RUNTIME DESTINATION bin |
| 118 | +) |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +install(PROGRAMS |
| 124 | + DESTINATION lib/${PROJECT_NAME} |
| 125 | +) |
| 126 | + |
| 127 | +# Install launch and config directories |
| 128 | +install( |
| 129 | + DIRECTORY launch config |
| 130 | + DESTINATION share/${PROJECT_NAME} |
| 131 | +) |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | +_ament_cmake_python_register_environment_hook() |
| 136 | + |
| 137 | + |
| 138 | +# ament_python_install_package(script/${PROJECT_NAME}) |
| 139 | +# ament_python_install_package(script/${PROJECT_NAME}) |
| 140 | + |
| 141 | + |
| 142 | +# Ament package declaration |
| 143 | +ament_package() |
0 commit comments