CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(lvi_sam)
  3. ######################
  4. ### Cmake flags
  5. ######################
  6. set(CMAKE_BUILD_TYPE "Release")
  7. set(CMAKE_CXX_FLAGS "-std=c++14")
  8. set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -pthread")
  9. ######################
  10. ### Packages
  11. ######################
  12. find_package(catkin REQUIRED COMPONENTS
  13. tf
  14. roscpp
  15. rospy
  16. roslib
  17. # msg
  18. std_msgs
  19. sensor_msgs
  20. geometry_msgs
  21. nav_msgs
  22. # cv
  23. cv_bridge
  24. # pcl
  25. pcl_conversions
  26. # msg generation
  27. message_generation
  28. )
  29. find_package(OpenMP REQUIRED)
  30. find_package(PCL REQUIRED)
  31. find_package(OpenCV REQUIRED)
  32. find_package(Ceres REQUIRED)
  33. find_package(GTSAM REQUIRED QUIET)
  34. find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
  35. find_package(RapidJSON)
  36. ######################
  37. ### Message generation
  38. ######################
  39. add_message_files(
  40. DIRECTORY msg
  41. FILES
  42. cloud_info.msg
  43. )
  44. generate_messages(
  45. DEPENDENCIES
  46. geometry_msgs
  47. std_msgs
  48. nav_msgs
  49. sensor_msgs
  50. )
  51. ######################
  52. ### Catkin
  53. ######################
  54. catkin_package(
  55. DEPENDS PCL GTSAM
  56. )
  57. include_directories(
  58. ${catkin_INCLUDE_DIRS}
  59. ${PCL_INCLUDE_DIRS}
  60. ${OpenCV_INCLUDE_DIRS}
  61. ${CERES_INCLUDE_DIRS}
  62. ${Boost_INCLUDE_DIRS}
  63. )
  64. link_directories(
  65. ${PCL_LIBRARY_DIRS}
  66. ${OpenCV_LIBRARY_DIRS}
  67. ${GTSAM_LIBRARY_DIRS}
  68. )
  69. ######################
  70. ### visual odometry
  71. ######################
  72. file(GLOB visual_feature_files
  73. "src/visual_odometry/visual_feature/*.cpp"
  74. "src/visual_odometry/visual_feature/camera_models/*.cc"
  75. )
  76. file(GLOB visual_odometry_files
  77. "src/visual_odometry/visual_estimator/*.cpp"
  78. "src/visual_odometry/visual_estimator/factor/*.cpp"
  79. "src/visual_odometry/visual_estimator/initial/*.cpp"
  80. "src/visual_odometry/visual_estimator/utility/*.cpp"
  81. )
  82. file(GLOB visual_loop_files
  83. "src/visual_odometry/visual_loop/*.cpp"
  84. "src/visual_odometry/visual_loop/utility/*.cpp"
  85. "src/visual_odometry/visual_loop/ThirdParty/*.cpp"
  86. "src/visual_odometry/visual_loop/ThirdParty/DBoW/*.cpp"
  87. "src/visual_odometry/visual_loop/ThirdParty/DUtils/*.cpp"
  88. "src/visual_odometry/visual_loop/ThirdParty/DVision/*.cpp"
  89. "src/visual_odometry/visual_feature/camera_models/*.cc"
  90. )
  91. # Visual Feature Tracker
  92. add_executable(${PROJECT_NAME}_visual_feature ${visual_feature_files})
  93. target_link_libraries(${PROJECT_NAME}_visual_feature ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})
  94. # Visual Odometry
  95. add_executable(${PROJECT_NAME}_visual_odometry ${visual_odometry_files})
  96. target_link_libraries(${PROJECT_NAME}_visual_odometry ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})
  97. # Visual Lopp
  98. add_executable(${PROJECT_NAME}_visual_loop ${visual_loop_files})
  99. target_link_libraries(${PROJECT_NAME}_visual_loop ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})
  100. ######################
  101. ### lidar odometry
  102. ######################
  103. # IMU Preintegration
  104. add_executable(${PROJECT_NAME}_imuPreintegration src/lidar_odometry/imuPreintegration.cpp)
  105. target_link_libraries(${PROJECT_NAME}_imuPreintegration ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} gtsam)
  106. # Range Image Projection
  107. add_executable(${PROJECT_NAME}_imageProjection src/lidar_odometry/imageProjection.cpp)
  108. add_dependencies(${PROJECT_NAME}_imageProjection ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  109. target_link_libraries(${PROJECT_NAME}_imageProjection ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
  110. # Feature Association
  111. add_executable(${PROJECT_NAME}_featureExtraction src/lidar_odometry/featureExtraction.cpp)
  112. add_dependencies(${PROJECT_NAME}_featureExtraction ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  113. target_link_libraries(${PROJECT_NAME}_featureExtraction ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
  114. # Mapping Optimization
  115. add_executable(${PROJECT_NAME}_mapOptmization src/lidar_odometry/mapOptmization.cpp)
  116. add_dependencies(${PROJECT_NAME}_mapOptmization ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  117. target_compile_options(${PROJECT_NAME}_mapOptmization PRIVATE ${OpenMP_CXX_FLAGS})
  118. target_link_libraries(${PROJECT_NAME}_mapOptmization PRIVATE ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${OpenMP_CXX_FLAGS} gtsam)