CMakeLists.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. cmake_minimum_required(VERSION 2.8.3)
  2. project(localizer)
  3. set(CMAKE_CXX_STANDARD 14)
  4. option(BUILD_VGICP_CUDA "Build GPU-powered VGICP" OFF)
  5. option(BUILD_apps "Build application programs" ON)
  6. option(BUILD_test "Build test programs" OFF)
  7. option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
  8. find_package(catkin REQUIRED COMPONENTS
  9. roscpp
  10. tf2
  11. tf2_ros
  12. tf2_geometry_msgs
  13. std_msgs
  14. geometry_msgs
  15. sensor_msgs
  16. nav_msgs
  17. diagnostic_msgs
  18. pcl_conversions
  19. pcl_ros
  20. message_generation
  21. )
  22. generate_messages(
  23. DEPENDENCIES
  24. std_msgs
  25. )
  26. find_package(OpenCV REQUIRED)
  27. find_package(PCL REQUIRED QUIET)
  28. find_package(OpenMP REQUIRED)
  29. catkin_package(
  30. INCLUDE_DIRS include
  31. CATKIN_DEPENDS
  32. roscpp
  33. tf2
  34. tf2_ros
  35. tf2_geometry_msgs
  36. geometry_msgs
  37. sensor_msgs
  38. nav_msgs
  39. diagnostic_msgs
  40. pcl_conversions
  41. pcl_ros
  42. message_generation
  43. )
  44. find_package(OpenMP)
  45. if (OPENMP_FOUND)
  46. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  47. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  48. endif()
  49. if(BUILD_VGICP_CUDA)
  50. find_package(CUDA REQUIRED)
  51. include_directories(${CUDA_INCLUDE_DIRS})
  52. link_directories(${CUDA_LIBRARY_DIRS})
  53. endif()
  54. find_package(RapidJSON)
  55. ###################################
  56. ## catkin specific configuration ##
  57. ###################################
  58. if(catkin_FOUND)
  59. catkin_package(
  60. INCLUDE_DIRS include
  61. LIBRARIES fast_gicp
  62. )
  63. endif()
  64. include_directories(include
  65. ${catkin_INCLUDE_DIRS}
  66. ${OpenCV_INCLUDE_DIRS}
  67. )
  68. add_library(localizer SHARED
  69. src/fast_gicp/gicp/lsq_registration.cpp
  70. src/fast_gicp/gicp/fast_gicp.cpp
  71. src/fast_gicp/gicp/fast_gicp_st.cpp
  72. src/fast_gicp/gicp/fast_vgicp.cpp
  73. )
  74. target_link_libraries(localizer
  75. ${PCL_LIBRARIES}
  76. )
  77. target_include_directories(localizer PUBLIC
  78. include
  79. ${PCL_INCLUDE_DIRS}
  80. ${EIGEN3_INCLUDE_DIR}
  81. )
  82. ### CUDA ###
  83. if(BUILD_VGICP_CUDA)
  84. set(CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
  85. add_definitions(-DUSE_VGICP_CUDA)
  86. cuda_add_library(localizer_cuda SHARED
  87. src/fast_gicp/cuda/fast_vgicp_cuda.cu
  88. src/fast_gicp/cuda/brute_force_knn.cu
  89. src/fast_gicp/cuda/covariance_estimation.cu
  90. src/fast_gicp/cuda/covariance_estimation_rbf.cu
  91. src/fast_gicp/cuda/covariance_regularization.cu
  92. src/fast_gicp/cuda/gaussian_voxelmap.cu
  93. src/fast_gicp/cuda/find_voxel_correspondences.cu
  94. src/fast_gicp/cuda/compute_derivatives.cu
  95. src/fast_gicp/cuda/compute_mahalanobis.cu
  96. src/fast_gicp/cuda/ndt_cuda.cu
  97. src/fast_gicp/cuda/ndt_compute_derivatives.cu
  98. )
  99. target_include_directories(localizer_cuda PRIVATE
  100. include
  101. thirdparty/Eigen
  102. thirdparty/nvbio
  103. ${catkin_INCLUDE_DIRS}
  104. )
  105. target_link_libraries(localizer_cuda
  106. ${catkin_LIBRARIES}
  107. )
  108. cuda_add_cublas_to_target(localizer_cuda)
  109. # add vgicp_cuda to libfast_gicp
  110. target_sources(localizer PRIVATE
  111. src/fast_gicp/gicp/fast_vgicp_cuda.cpp
  112. src/fast_gicp/ndt/ndt_cuda.cpp
  113. )
  114. target_link_libraries(localizer
  115. localizer_cuda
  116. )
  117. add_dependencies(localizer localizer_cuda)
  118. if(catkin_FOUND)
  119. install(TARGETS localizer_cuda
  120. LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
  121. endif()
  122. endif()
  123. ###########
  124. ## Build ##
  125. ###########
  126. include_directories(include ${catkin_INCLUDE_DIRS})
  127. SET(CMAKE_CXX_FLAGS "-O2 -g -Wall ${CMAKE_CXX_FLAGS}")
  128. add_executable(map_loader src/map_loader.cpp)
  129. target_link_libraries(map_loader ${catkin_LIBRARIES} ${PCL_LIBRARIES})
  130. add_executable(deskew_point_cloud src/deskew_point_cloud.cpp)
  131. target_link_libraries(deskew_point_cloud ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
  132. add_executable(localizer_node src/localizer.cpp src/localizer_node.cpp)
  133. target_link_libraries(localizer_node ${catkin_LIBRARIES} ${PCL_LIBRARIES} localizer )
  134. #############
  135. ## Install ##
  136. #############
  137. # all install targets should use catkin DESTINATION variables
  138. # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
  139. ## Mark executable scripts (Python etc.) for installation
  140. ## in contrast to setup.py, you can choose the destination
  141. # catkin_install_python(PROGRAMS
  142. # scripts/my_python_script
  143. # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  144. # )
  145. # Mark executables for installation
  146. # See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
  147. install(TARGETS map_loader deskew_point_cloud localizer_node
  148. RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
  149. )
  150. ## Mark libraries for installation
  151. ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
  152. # install(TARGETS ${PROJECT_NAME}
  153. # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  154. # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  155. # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
  156. # )
  157. # Mark cpp header files for installation
  158. install(DIRECTORY include/${PROJECT_NAME}/
  159. DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
  160. FILES_MATCHING PATTERN "*.h"
  161. PATTERN ".svn" EXCLUDE
  162. )
  163. # Mark other files for installation (e.g. launch and bag files, etc.)
  164. install(FILES
  165. # myfile1
  166. # myfile2
  167. launch/deskw_point_cloud.launch
  168. launch/localizer.launch
  169. launch/map_loader.launch
  170. launch/run.launch
  171. launch/lexus.launch
  172. launch/static_tf.launch
  173. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  174. )
  175. #############
  176. ## Testing ##
  177. #############
  178. ## Add gtest based cpp test target and link libraries
  179. # catkin_add_gtest(${PROJECT_NAME}-test test/test_math_tool.cpp)
  180. # if(TARGET ${PROJECT_NAME}-test)
  181. # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
  182. # endif()
  183. ## Add folders to be run by python nosetests
  184. # catkin_add_nosetests(test)