CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(fast_lio_sam)
  3. SET(CMAKE_BUILD_TYPE "Release")
  4. ADD_COMPILE_OPTIONS(-std=c++14 )
  5. ADD_COMPILE_OPTIONS(-std=c++14 )
  6. set( CMAKE_CXX_FLAGS "-std=c++14 -O3" )
  7. add_definitions(-DROOT_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\")
  8. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
  9. set(CMAKE_CXX_STANDARD 14)
  10. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  11. set(CMAKE_CXX_EXTENSIONS OFF)
  12. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread -std=c++0x -std=c++14 -fexceptions")
  13. message("Current CPU archtecture: ${CMAKE_SYSTEM_PROCESSOR}")
  14. if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)" )
  15. include(ProcessorCount)
  16. ProcessorCount(N)
  17. message("Processer number: ${N}")
  18. if(N GREATER 4)
  19. add_definitions(-DMP_EN)
  20. add_definitions(-DMP_PROC_NUM=3)
  21. message("core for MP: 3")
  22. elseif(N GREATER 3)
  23. add_definitions(-DMP_EN)
  24. add_definitions(-DMP_PROC_NUM=2)
  25. message("core for MP: 2")
  26. else()
  27. add_definitions(-DMP_PROC_NUM=1)
  28. endif()
  29. else()
  30. add_definitions(-DMP_PROC_NUM=1)
  31. endif()
  32. find_package(OpenMP QUIET)
  33. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  34. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  35. find_package(Boost 1.43 COMPONENTS serialization system filesystem thread program_options date_time timer chrono)
  36. find_package(PythonLibs REQUIRED)
  37. find_path(MATPLOTLIB_CPP_INCLUDE_DIRS "matplotlibcpp.h")
  38. find_package(catkin REQUIRED COMPONENTS
  39. geometry_msgs
  40. nav_msgs
  41. sensor_msgs
  42. roscpp
  43. rospy
  44. std_msgs
  45. pcl_ros
  46. tf
  47. livox_ros_driver
  48. message_generation
  49. eigen_conversions
  50. )
  51. find_package(Eigen3 REQUIRED)
  52. find_package(PCL REQUIRED)
  53. #find_package (GeographicLib REQUIRED)
  54. find_package( GTSAMCMakeTools )
  55. find_package(GTSAM REQUIRED QUIET)
  56. message(Eigen: ${EIGEN3_INCLUDE_DIR})
  57. include_directories(
  58. ${catkin_INCLUDE_DIRS}
  59. ${EIGEN3_INCLUDE_DIR}
  60. ${PCL_INCLUDE_DIRS}
  61. ${PYTHON_INCLUDE_DIRS}
  62. ${GTSAM_INCLUDE_DIR}
  63. #${GeographicLib_INCLUDE_DIRS}
  64. include)
  65. # link directories
  66. # link_directories(
  67. # ${GTSAM_LIBRARY_DIRS}
  68. # )
  69. add_message_files(
  70. FILES
  71. Pose6D.msg
  72. )
  73. add_service_files(
  74. DIRECTORY srv
  75. FILES
  76. save_map.srv
  77. save_pose.srv
  78. )
  79. generate_messages(
  80. DEPENDENCIES
  81. geometry_msgs
  82. )
  83. catkin_package(
  84. CATKIN_DEPENDS geometry_msgs nav_msgs roscpp rospy std_msgs message_runtime
  85. DEPENDS EIGEN3 PCL GTSAM
  86. INCLUDE_DIRS
  87. )
  88. # add_executable(fastlio_sam_mapping src/laserMapping.cpp include/ikd-Tree/ikd_Tree.cpp src/preprocess.cpp)
  89. # target_link_libraries(fastlio_sam_mapping ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${PYTHON_LIBRARIES})
  90. # target_include_directories(fastlio_sam_mapping PRIVATE ${PYTHON_INCLUDE_DIRS})
  91. add_library(ikd_Tree include/ikd-Tree/ikd_Tree.cpp)
  92. add_library(preprocess src/preprocess.cpp)
  93. add_executable(fastlio_sam_mapping src/laserMapping.cpp src/scancontext/Scancontext.cpp src/keyFramesManager.cpp src/keyFramesManager.h)
  94. target_link_libraries(fastlio_sam_mapping ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${PYTHON_LIBRARIES} ikd_Tree preprocess gtsam) #${GeographicLib_LIBRARIES}
  95. target_include_directories(fastlio_sam_mapping PRIVATE ${PYTHON_INCLUDE_DIRS})