CMakeLists.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # Copyright(c) 2019 livoxtech limited.
  2. cmake_minimum_required(VERSION 2.8.3)
  3. #---------------------------------------------------------------------------------------
  4. # Start livox_ros_driver project
  5. #---------------------------------------------------------------------------------------
  6. project(lio_livox_cpp)
  7. #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  8. SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  9. #---------------------------------------------------------------------------------------
  10. # find package and the dependecy
  11. #---------------------------------------------------------------------------------------
  12. find_package(Boost 1.54 REQUIRED COMPONENTS
  13. system
  14. thread
  15. chrono
  16. )
  17. find_package (Eigen3 REQUIRED CONFIG QUIET)
  18. find_package(Pangolin 0.8 REQUIRED)
  19. find_package(PCL REQUIRED)
  20. find_package(Ceres REQUIRED)
  21. find_package(OpenCV REQUIRED)
  22. find_package(SuiteSparse REQUIRED)
  23. find_package(PkgConfig)
  24. pkg_check_modules(APR apr-1)
  25. if (APR_FOUND)
  26. message(${APR_INCLUDE_DIRS})
  27. message(${APR_LIBRARIES})
  28. endif (APR_FOUND)
  29. #---------------------------------------------------------------------------------------
  30. # Set default build to release
  31. #---------------------------------------------------------------------------------------
  32. if(NOT CMAKE_BUILD_TYPE)
  33. set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
  34. endif()
  35. #---------------------------------------------------------------------------------------
  36. # Compiler config
  37. #---------------------------------------------------------------------------------------
  38. set(CMAKE_CXX_STANDARD 17)
  39. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  40. set(CMAKE_CXX_EXTENSIONS OFF)
  41. ## make sure the livox_sdk_static library is installed
  42. find_library(LIVOX_SDK_LIBRARY liblivox_sdk_static.a /usr/local/lib)
  43. if((NOT LIVOX_SDK_LIBRARY) OR (NOT EXISTS ${LIVOX_SDK_LIBRARY}))
  44. # couldn't find the livox sdk library
  45. message("Coudn't find livox sdk library!")
  46. message("Download Livox-SDK from github and build&install it please!")
  47. message("Download Livox-SDK from github and build&install it please!")
  48. message("Download Livox-SDK from github and build&install it please!")
  49. message("git clone Livox-SDK from github temporarily, only for ROS distro jenkins build!")
  50. # clone livox sdk source code from github
  51. execute_process(COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/Livox-SDK OUTPUT_VARIABLE cmd_res)
  52. message("Try to pull the livox sdk source code from github")
  53. FOREACH(res ${cmd_res})
  54. MESSAGE(${res})
  55. ENDFOREACH()
  56. execute_process(COMMAND git clone https://github.com/Livox-SDK/Livox-SDK.git ${CMAKE_CURRENT_SOURCE_DIR}/Livox-SDK OUTPUT_VARIABLE cmd_res)
  57. FOREACH(res ${cmd_res})
  58. MESSAGE(${res})
  59. ENDFOREACH()
  60. execute_process(COMMAND cmake .. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Livox-SDK/build OUTPUT_VARIABLE cmd_res)
  61. FOREACH(res ${cmd_res})
  62. MESSAGE(${res})
  63. ENDFOREACH()
  64. execute_process(COMMAND make WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Livox-SDK/build OUTPUT_VARIABLE cmd_res)
  65. FOREACH(res ${cmd_res})
  66. MESSAGE(${res})
  67. ENDFOREACH()
  68. include_directories(
  69. ./
  70. ${CMAKE_CURRENT_SOURCE_DIR}/Livox-SDK/sdk_core/include
  71. )
  72. link_directories(
  73. ./
  74. ${CMAKE_CURRENT_SOURCE_DIR}/Livox-SDK/build/sdk_core
  75. )
  76. else()
  77. message("find livox sdk library success")
  78. endif()
  79. include_directories(
  80. define
  81. lio/include
  82. lio/src
  83. ${Pangolin_INCLUDE_DIRS}
  84. ${catkin_INCLUDE_DIRS}
  85. ${EIGEN3_INCLUDE_DIR}
  86. ${PCL_INCLUDE_DIRS}
  87. ${CERES_INCLUDE_DIRS}
  88. ${OpenCV_INCLUDE_DIRS}
  89. ${SUITESPARSE_INCLUDE_DIRS}
  90. ${APR_INCLUDE_DIRS}
  91. livox/common
  92. livox/common/rapidjson
  93. livox/comon/rapdidxml
  94. livox/common/comm
  95. livox/timesync
  96. livox/timesync/user_uart
  97. livox/livox_driver)
  98. ## PCL library
  99. link_directories(${PCL_LIBRARY_DIRS})
  100. add_definitions(${PCL_DEFINITIONS})
  101. #---------------------------------------------------------------------------------------
  102. # generate excutable and add libraries
  103. #---------------------------------------------------------------------------------------
  104. add_executable(${PROJECT_NAME}_node
  105. lio/src/PoseEstimation.cpp
  106. lio/src/segment/LidarFeatureExtractor.cpp
  107. lio/src/segment/segment.cpp
  108. lio/src/segment/pointsCorrect.cpp
  109. lio/src/lio/LocalMapIvox.cpp
  110. lio/src/lio/mapper.cpp
  111. lio/src/lio/Estimator.cpp
  112. lio/src/lio/IMUIntegrator.cpp
  113. lio/src/lio/ceresfunc.cpp
  114. livox/livox_driver/lvx_file.cpp
  115. livox/livox_driver/ldq.cpp
  116. livox/livox_driver/lds.cpp
  117. livox/livox_driver/lds_lvx.cpp
  118. livox/livox_driver/lds_lidar.cpp
  119. livox/livox_driver/lds_hub.cpp
  120. livox/livox_driver/lddc.cpp
  121. livox/timesync/timesync.cpp
  122. livox/timesync/user_uart/user_uart.cpp
  123. livox/common/comm/comm_protocol.cpp
  124. livox/common/comm/sdk_protocol.cpp
  125. livox/common/comm/gps_protocol.cpp
  126. )
  127. #---------------------------------------------------------------------------------------
  128. # precompile macro and compile option
  129. #---------------------------------------------------------------------------------------
  130. target_compile_options(${PROJECT_NAME}_node
  131. PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall>
  132. )
  133. #---------------------------------------------------------------------------------------
  134. # link libraries
  135. #---------------------------------------------------------------------------------------
  136. target_link_libraries(${PROJECT_NAME}_node
  137. pango_display
  138. livox_sdk_static.a
  139. ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${CERES_LIBRARIES}
  140. ${Boost_LIBRARY}
  141. ${APR_LIBRARIES}
  142. -lpthread
  143. )
  144. #---------------------------------------------------------------------------------------
  145. # end of CMakeList.txt
  146. #---------------------------------------------------------------------------------------