|
| 1 | +cmake_minimum_required(VERSION 3.5) |
| 2 | + |
| 3 | +# Set default build type. |
| 4 | +if(NOT CMAKE_BUILD_TYPE) |
| 5 | + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build type: Release" FORCE) |
| 6 | +endif() |
| 7 | + |
| 8 | +project(fuser) |
| 9 | + |
| 10 | +# Default to C++14 |
| 11 | +if(NOT CMAKE_CXX_STANDARD) |
| 12 | + set(CMAKE_CXX_STANDARD 14) |
| 13 | +endif() |
| 14 | + |
| 15 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 16 | + add_compile_options(-Wall -Wextra -Wpedantic -Wno-implicit-fallthrough -Wno-maybe-uninitialized) |
| 17 | +endif() |
| 18 | + |
| 19 | +if(NOT HOST_COMPILATION) |
| 20 | + ADD_DEFINITIONS(-D__ANDROID__) |
| 21 | +endif() |
| 22 | + |
| 23 | +# Compilation options to set various features of the nodes. |
| 24 | +# Activate them when building with colcon using: |
| 25 | +# colcon build [...] --ament-cmake-args "-DOPTION=ON/OFF" "[...]" [...] |
| 26 | +# Quote each option separately!!! |
| 27 | +option(PX4 "Enable publishers of VIO data for PX4" OFF) |
| 28 | +option(SMT "Enable multithreaded processing" ON) |
| 29 | +option(DEBUG "Enable debug symbols and related compilation options" OFF) |
| 30 | + |
| 31 | +find_package(ament_cmake REQUIRED) |
| 32 | +find_package(rclcpp REQUIRED) |
| 33 | +find_package(std_msgs REQUIRED) |
| 34 | +find_package(sensor_msgs REQUIRED) |
| 35 | +find_package(eigen3_cmake_module REQUIRED) |
| 36 | +find_package(Eigen3 3.1.0 REQUIRED) |
| 37 | +find_package(Pangolin REQUIRED) |
| 38 | +if(PX4) |
| 39 | + find_package(px4_msgs REQUIRED) |
| 40 | +endif() |
| 41 | + |
| 42 | +find_package(OpenCV 4.5.1 QUIET) |
| 43 | +if(NOT OpenCV_FOUND) |
| 44 | + message(FATAL_ERROR "OpenCV > 4.5.1 not found.") |
| 45 | +endif() |
| 46 | +find_package(realsense2 REQUIRED) |
| 47 | + |
| 48 | +if(NOT HOST_COMPILATION) |
| 49 | + find_package(CUDA REQUIRED) |
| 50 | + include_directories("${CUDA_INCLUDE_DIRS}" |
| 51 | + /usr/local/include/ORB_SLAM2 |
| 52 | + ${PROJECT_SOURCE_DIR}/Drivers/RealSense |
| 53 | + ${PROJECT_SOURCE_DIR}/include |
| 54 | + ${EIGEN3_INCLUDE_DIR}) |
| 55 | +else() |
| 56 | + include_directories(/usr/local/include/ORB_SLAM2 |
| 57 | + ${PROJECT_SOURCE_DIR}/Drivers/RealSense |
| 58 | + ${PROJECT_SOURCE_DIR}/include |
| 59 | + ${EIGEN3_INCLUDE_DIR}) |
| 60 | +endif() |
| 61 | + |
| 62 | +# Activate debugging features. |
| 63 | +if(DEBUG) |
| 64 | + message(STATUS "Activating debugging features") |
| 65 | + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Debug build" FORCE) |
| 66 | +endif() |
| 67 | + |
| 68 | +# Check build type. |
| 69 | +if(CMAKE_BUILD_TYPE MATCHES Release) |
| 70 | + message(STATUS "Release build type selected") |
| 71 | +elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) |
| 72 | + message(STATUS "Debug build type selected") |
| 73 | +endif() |
| 74 | + |
| 75 | +set(LIBS -lfbow |
| 76 | + -lDLib |
| 77 | + -lg2o |
| 78 | + -lORB_SLAM2 |
| 79 | + -lboost_system) |
| 80 | + |
| 81 | +add_executable(${PROJECT_NAME} src/fuser.cc src/pose.cc Drivers/RealSense/realsense.cc |
| 82 | + src/fuser_ros2.cpp |
| 83 | + src/fuser_node.cpp) |
| 84 | + |
| 85 | +if(PX4) |
| 86 | + ament_target_dependencies(${PROJECT_NAME} rclcpp |
| 87 | + std_msgs |
| 88 | + sensor_msgs |
| 89 | + Eigen3 |
| 90 | + Pangolin |
| 91 | + px4_msgs |
| 92 | + OpenCV |
| 93 | + realsense2) |
| 94 | +else() |
| 95 | + ament_target_dependencies(${PROJECT_NAME} rclcpp |
| 96 | + std_msgs |
| 97 | + sensor_msgs |
| 98 | + Eigen3 |
| 99 | + Pangolin |
| 100 | + OpenCV |
| 101 | + realsense2) |
| 102 | +endif() |
| 103 | + |
| 104 | +target_link_libraries(${PROJECT_NAME} ${LIBS} ${realsense2_LIBRARY} ${OpenCV_LIBS}) |
| 105 | + |
| 106 | +# Activate features in the code from the options described above. |
| 107 | +if(PX4) |
| 108 | + message(STATUS "Activating PX4 integrations") |
| 109 | + target_compile_definitions(${PROJECT_NAME} PUBLIC PX4) |
| 110 | +endif() |
| 111 | +if(SMT) |
| 112 | + message(STATUS "Selecting parallel implementation") |
| 113 | + target_compile_definitions(${PROJECT_NAME} PUBLIC SMT) |
| 114 | +endif() |
| 115 | + |
| 116 | +install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}) |
| 117 | + |
| 118 | +install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME}) |
| 119 | + |
| 120 | +ament_package() |
0 commit comments