CMakeLists.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #############################################################
  2. # #
  3. # Copyright (c) 2021, University of California, Los Angeles #
  4. # #
  5. # Authors: Kenny J. Chen, Brett T. Lopez #
  6. # Contact: kennyjchen@ucla.edu, btlopez@ucla.edu #
  7. # #
  8. #############################################################
  9. cmake_minimum_required(VERSION 3.10.0)
  10. project(direct_lidar_odometry)
  11. add_compile_options(-std=c++14)
  12. set(CMAKE_BUILD_TYPE "Release")
  13. find_package( PCL REQUIRED )
  14. include_directories(${PCL_INCLUDE_DIRS})
  15. add_definitions(${PCL_DEFINITIONS})
  16. link_directories(${PCL_LIBRARY_DIRS})
  17. find_package( Eigen3 REQUIRED )
  18. include_directories(${EIGEN3_INCLUDE_DIR})
  19. include(FindOpenMP)
  20. if(OPENMP_FOUND)
  21. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  22. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  23. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  24. else(OPENMP_FOUND)
  25. message("ERROR: OpenMP could not be found.")
  26. endif(OPENMP_FOUND)
  27. set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  28. set(THREADS_PREFER_PTHREAD_FLAG TRUE)
  29. find_package(Threads REQUIRED)
  30. find_package(catkin REQUIRED COMPONENTS
  31. roscpp
  32. std_msgs
  33. sensor_msgs
  34. geometry_msgs
  35. pcl_ros
  36. )
  37. catkin_package(
  38. CATKIN_DEPENDS
  39. roscpp
  40. std_msgs
  41. sensor_msgs
  42. geometry_msgs
  43. pcl_ros
  44. INCLUDE_DIRS
  45. include
  46. LIBRARIES
  47. ${PROJECT_NAME}
  48. nano_gicp
  49. nanoflann
  50. )
  51. include_directories(include ${catkin_INCLUDE_DIRS})
  52. # NanoFLANN
  53. add_library(nanoflann SHARED
  54. src/nano_gicp/nanoflann.cc
  55. )
  56. target_link_libraries(nanoflann ${PCL_LIBRARIES})
  57. target_include_directories(nanoflann PUBLIC include ${PCL_INCLUDE_DIRS})
  58. # NanoGICP
  59. add_library(nano_gicp SHARED
  60. src/nano_gicp/lsq_registration.cc
  61. src/nano_gicp/nano_gicp.cc
  62. )
  63. target_link_libraries(nano_gicp ${PCL_LIBRARIES} ${OpenMP_LIBS} nanoflann)
  64. target_include_directories(nano_gicp PUBLIC include ${PCL_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
  65. # Odometry Node
  66. add_executable(dlo_odom_node src/dlo/odom_node.cc src/dlo/odom.cc)
  67. add_dependencies(dlo_odom_node ${catkin_EXPORTED_TARGETS})
  68. target_compile_options(dlo_odom_node PRIVATE ${OpenMP_FLAGS})
  69. target_link_libraries(dlo_odom_node ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenMP_LIBS} Threads::Threads nano_gicp)
  70. # Mapping Node
  71. add_executable (dlo_map_node src/dlo/map_node.cc src/dlo/map.cc)
  72. add_dependencies(dlo_map_node ${catkin_EXPORTED_TARGETS})
  73. target_compile_options(dlo_map_node PRIVATE ${OpenMP_FLAGS})
  74. target_link_libraries(dlo_map_node ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenMP_LIBS} Threads::Threads)