CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(lio_sam)
  3. set(CMAKE_BUILD_TYPE "Release")
  4. set(CMAKE_CXX_FLAGS "-std=c++14")
  5. set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -pthread")
  6. find_package(catkin REQUIRED COMPONENTS
  7. tf
  8. roscpp
  9. rospy
  10. cv_bridge
  11. # pcl library
  12. pcl_conversions
  13. # msgs
  14. std_msgs
  15. sensor_msgs
  16. geometry_msgs
  17. nav_msgs
  18. message_generation
  19. )
  20. find_package(OpenMP REQUIRED)
  21. find_package(PCL REQUIRED QUIET)
  22. find_package(OpenCV REQUIRED QUIET)
  23. find_package(GTSAM REQUIRED QUIET)
  24. find_package(RapidJSON)
  25. add_message_files(
  26. DIRECTORY msg
  27. FILES
  28. cloud_info.msg
  29. )
  30. generate_messages(
  31. DEPENDENCIES
  32. geometry_msgs
  33. std_msgs
  34. nav_msgs
  35. sensor_msgs
  36. )
  37. catkin_package(
  38. INCLUDE_DIRS include
  39. DEPENDS PCL GTSAM
  40. CATKIN_DEPENDS
  41. std_msgs
  42. nav_msgs
  43. geometry_msgs
  44. sensor_msgs
  45. message_runtime
  46. message_generation
  47. )
  48. # include directories
  49. include_directories(
  50. include
  51. ${catkin_INCLUDE_DIRS}
  52. ${PCL_INCLUDE_DIRS}
  53. ${OpenCV_INCLUDE_DIRS}
  54. ${GTSAM_INCLUDE_DIR}
  55. )
  56. # link directories
  57. link_directories(
  58. include
  59. ${PCL_LIBRARY_DIRS}
  60. ${OpenCV_LIBRARY_DIRS}
  61. ${GTSAM_LIBRARY_DIRS}
  62. )
  63. ###########
  64. ## Build ##
  65. ###########
  66. # Range Image Projection
  67. add_executable(${PROJECT_NAME}_imageProjection src/imageProjection.cpp)
  68. add_dependencies(${PROJECT_NAME}_imageProjection ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  69. target_link_libraries(${PROJECT_NAME}_imageProjection ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
  70. # Feature Association
  71. add_executable(${PROJECT_NAME}_featureExtraction src/featureExtraction.cpp)
  72. add_dependencies(${PROJECT_NAME}_featureExtraction ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  73. target_link_libraries(${PROJECT_NAME}_featureExtraction ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
  74. # Mapping Optimization
  75. add_executable(${PROJECT_NAME}_mapOptmization src/mapOptmization.cpp)
  76. add_dependencies(${PROJECT_NAME}_mapOptmization ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  77. target_compile_options(${PROJECT_NAME}_mapOptmization PRIVATE ${OpenMP_CXX_FLAGS})
  78. target_link_libraries(${PROJECT_NAME}_mapOptmization ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${OpenMP_CXX_FLAGS} gtsam)
  79. # localization
  80. add_executable(${PROJECT_NAME}_localization src/localization.cpp)
  81. add_dependencies(${PROJECT_NAME}_localization ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
  82. target_compile_options(${PROJECT_NAME}_localization PRIVATE ${OpenMP_CXX_FLAGS})
  83. target_link_libraries(${PROJECT_NAME}_localization ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${OpenMP_CXX_FLAGS} gtsam)
  84. # IMU Preintegration
  85. add_executable(${PROJECT_NAME}_imuPreintegration src/imuPreintegration.cpp)
  86. target_link_libraries(${PROJECT_NAME}_imuPreintegration ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} gtsam)
  87. #############
  88. ## Install ##
  89. #############
  90. # all install targets should use catkin DESTINATION variables
  91. # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
  92. ## Mark executable scripts (Python etc.) for installation
  93. ## in contrast to setup.py, you can choose the destination
  94. # catkin_install_python(PROGRAMS
  95. # scripts/my_python_script
  96. # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  97. # )
  98. ## Mark executables for installation
  99. ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
  100. install(TARGETS
  101. ${PROJECT_NAME}_imageProjection
  102. ${PROJECT_NAME}_featureExtraction
  103. ${PROJECT_NAME}_mapOptmization
  104. ${PROJECT_NAME}_localization
  105. ${PROJECT_NAME}_imuPreintegration
  106. RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  107. )
  108. #
  109. ## Mark libraries for installation
  110. ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
  111. # install(TARGETS ${PROJECT_NAME}
  112. # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  113. # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  114. # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
  115. # )
  116. # Mark cpp header files for installation
  117. install(DIRECTORY include/${PROJECT_NAME}/
  118. DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  119. FILES_MATCHING PATTERN "*.h"
  120. PATTERN ".svn" EXCLUDE
  121. )
  122. # Mark cpp header files for installation
  123. install(DIRECTORY
  124. launch
  125. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  126. )
  127. # Mark cpp header files for installation
  128. install(DIRECTORY
  129. config
  130. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  131. )
  132. ## Mark other files for installation (e.g. launch and bag files, etc.)
  133. # install(FILES
  134. # # myfile1
  135. # # myfile2
  136. # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  137. # )