ap108

CMakeLists.txt

Dec 15th, 2016
169
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cmake_minimum_required(VERSION 2.6)
  2. cmake_policy(SET CMP0003 NEW)
  3. #########################################################
  4. ### USER CONFIG #########################################
  5. #########################################################
  6. set(USE_SIFT_GPU 1 CACHE BOOL "build with support for siftgpu")
  7. if (${USE_SIFT_GPU})
  8. message(STATUS "SiftGPU library will be used")
  9. else (${USE_SIFT_GPU})
  10. message(STATUS "SiftGPU library will not be used")
  11. endif (${USE_SIFT_GPU})
  12.  
  13. #SIFT_GPU_MODE is now set via parameter server option "siftgpu_with_cuda"
  14. #set(ENV{SIFT_GPU_MODE} 2) #CUDA = 1, GLSL = 2
  15. set(ENV{SIFT_GPU_CUDA_PATH} /usr/local/cuda CACHE PATH "where cuda is installed")
  16.  
  17. #These settings are unsupported legacy
  18. set(USE_GICP_BIN 0)
  19. set(USE_GICP_CODE 0)
  20. set(USE_PCL_ICP 0)
  21. set(USE_GL2PS 0) #For printing the 3D Window to PostScript - requires installation of additional library: libgl2ps-dev
  22.  
  23. IF ("${ROS_PARALLEL_JOBS}" EQUAL "")
  24. set(ROS_PARALLEL_JOBS 1)
  25. endif ("${ROS_PARALLEL_JOBS}" EQUAL "")
  26. #set the default path for built executables to the "bin" directory
  27. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
  28. #set the default path for built libraries to the "lib" directory
  29. set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
  30. #SET(CMAKE_CXX_FLAGS "-O3 -fPIC -std=c++0x")
  31. #For annotated profiling with perf:
  32. #SET(CMAKE_CXX_FLAGS "-ggdb -O3 -fPIC -std=c++0x")
  33. SET(CMAKE_CXX_FLAGS "-ggdb -O3 -fPIC")
  34. IF (${USE_GL2PS})
  35. add_definitions(-DGL2PS)
  36. ENDIF (${USE_GL2PS})
  37. #is used for compiling the libraries
  38. set(USE_GICP 0)
  39. IF (${USE_GICP_BIN} OR ${USE_GICP_CODE})
  40. set(USE_GICP 1)
  41. ENDIF (${USE_GICP_BIN} OR ${USE_GICP_CODE})
  42.  
  43. #########################################################
  44. #########################################################
  45.  
  46.  
  47. ## Find catkin macros and libraries
  48. ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
  49. ## is used, also find other catkin packages
  50. ####################################################
  51. # ROS
  52. ####################################################
  53. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/")
  54. #message(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
  55. find_package(catkin REQUIRED COMPONENTS pcl_conversions pcl_ros roscpp image_transport cv_bridge sensor_msgs cmake_modules
  56. geometry_msgs visualization_msgs std_msgs tf message_generation message_filters rosbag rosconsole Eigen)
  57. find_package(catkin REQUIRED cmake_modules) #added this line
  58. project(rgbdslam)
  59.  
  60. #add_definitions(-DROSCONSOLE_SEVERITY_INFO)
  61.  
  62. add_service_files(DIRECTORY srv FILES rgbdslam_ros_ui.srv rgbdslam_ros_ui_b.srv rgbdslam_ros_ui_f.srv rgbdslam_ros_ui_s.srv)
  63. generate_messages()
  64. catkin_package(
  65. INCLUDE_DIRS include
  66. # LIBRARIES ...
  67. CATKIN_DEPENDS pcl_conversions pcl_ros roscpp sensor_msgs Eigen
  68. DEPENDS message_runtime std_msgs Eigen
  69. )
  70. include_directories(${catkin_INCLUDE_DIRS} ${Eigen_INCLUDE_DIRS})
  71. link_directories(${catkin_LIBRARY_DIRS})
  72. link_libraries(rgbdslam ${catkin_LIBRARIES})
  73.  
  74. ####################################################
  75. # Required 3rd party
  76. ####################################################
  77. # PCL #######################
  78. find_package(PCL 1.7 REQUIRED COMPONENTS common io)
  79. include_directories(${PCL_INCLUDE_DIRS})
  80. link_directories(${PCL_LIBRARY_DIRS})
  81. add_definitions(${PCL_DEFINITIONS})
  82.  
  83. # Octomap ###################
  84. find_package(octomap 1.6 REQUIRED)
  85. include_directories(BEFORE ${OCTOMAP_INCLUDE_DIRS})
  86. link_directories(${OCTOMAP_LIBRARY_DIRS})
  87. link_libraries(${OCTOMAP_LIBRARIES})
  88.  
  89. # g2o #######################
  90. find_package(G2O REQUIRED)
  91. include_directories(${G2O_INCLUDE_DIRS})
  92. link_directories(${G2O_LIBRARY_DIRS})
  93. link_libraries(${G2O_LIBRARIES})
  94. message("G2o-libraries " ${G2O_LIBRARIES})
  95.  
  96. # Qt ########################
  97. # http://qtnode.net/wiki/Qt4_with_cmake
  98. find_package(Qt4 REQUIRED)
  99. SET(QT_USE_QTXML TRUE)
  100. SET(QT_USE_QTOPENGL TRUE)
  101. ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
  102. include(${QT_USE_FILE})
  103.  
  104. # OpenMP ########################
  105. find_package(OpenMP)
  106. if (OPENMP_FOUND)
  107. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  108. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  109. endif()
  110. # This is necessary as all ui files etc will get dumped in the bottom of then binary directory.
  111. include_directories(${CMAKE_CURRENT_BINARY_DIR} ${QT_QTOPENGL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external/gicp/ann_1.1.2/include/ANN)
  112.  
  113. #get_directory_property(clean ADDITIONAL_MAKE_CLEAN_FILES)
  114. #SET(clean external/siftgpu/linux/bin/libsiftgpu.so)
  115. #set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${clean}")
  116.  
  117. LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
  118.  
  119.  
  120. SET(${CMAKE_LIBRARY_PATH} ${LIBRARY_OUTPUT_PATH})
  121. #SET(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE TRUE)
  122.  
  123.  
  124. #Only possible when not subscribing to point cloud topic. Possibly dangerous anyway, but halves storage space per point cloud
  125. #ADD_DEFINITIONS(-DRGB_IS_4TH_DIM)
  126. #ADD_DEFINITIONS(-DDO_FEATURE_OPTIMIZATION)
  127. #ADD_DEFINITIONS(-DHEMACLOUDS)
  128. ADD_DEFINITIONS(-DROSCONSOLE_MIN_SEVERITY=ROSCONSOLE_SEVERITY_INFO)
  129.  
  130. #############################
  131. # SiftGPU ###################
  132. #############################
  133. IF (${USE_SIFT_GPU})
  134. add_subdirectory(external)
  135. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/SiftGPU/src)
  136. link_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/SiftGPU/bin)
  137.  
  138. add_definitions(-DUSE_SIFT_GPU)
  139. ENDIF (${USE_SIFT_GPU})
  140.  
  141.  
  142.  
  143. #############################
  144. # GICP ######################
  145. #############################
  146. IF (${USE_GICP})
  147. SET(gicp_build_path ${CMAKE_SOURCE_DIR}/external/gicp/ann_1.1.2)
  148. FILE(MAKE_DIRECTORY ${gicp_build_path}/lib/)
  149. MESSAGE("\n------------------------------------------------------------------\n")
  150. MESSAGE("Compiling GICP...")
  151. EXECUTE_PROCESS(
  152. COMMAND make ${ROS_PARALLEL_JOBS} linux-g++
  153. WORKING_DIRECTORY ${gicp_build_path}
  154. RESULT_VARIABLE gicp_return
  155. )
  156. MESSAGE("\n------------------------------------------------------------------\n")
  157.  
  158. #on error
  159. IF (NOT ${gicp_return} EQUAL 0)
  160. MESSAGE(FATAL_ERROR "GICP cannot be compiled. Returned: ${gicp_return}")
  161. ENDIF (NOT ${gicp_return} EQUAL 0)
  162.  
  163. FILE(COPY ${gicp_build_path}/lib/libANN.a DESTINATION ${CMAKE_SOURCE_DIR}/lib/)
  164. ENDIF (${USE_GICP})
  165.  
  166. IF (${USE_GICP_BIN})
  167. add_definitions(-DUSE_ICP_BIN)
  168. ENDIF (${USE_GICP_BIN})
  169.  
  170. IF (${USE_GICP_CODE})
  171. add_definitions(-DUSE_ICP_CODE)
  172. ENDIF (${USE_GICP_CODE})
  173. IF (${USE_PCL_ICP})
  174. add_definitions(-DUSE_PCL_ICP)
  175. ENDIF (${USE_PCL_ICP})
  176.  
  177.  
  178.  
  179. #############################
  180. # OpenCV ####################
  181. #############################
  182. #For using SIFT and SURF provide your own opencv installation
  183. #via exporting a shell variable
  184. set(OpenCV_DIR $ENV{OpenCV_DIR})
  185. #or set it directly here, e.g.
  186. #set(OpenCV_DIR /home/endres/ros_indigo/opencv2/build/)
  187. #Then activate the following definition
  188. #add_definitions(-DCV_NONFREE)
  189.  
  190. IF (NOT "${OpenCV_DIR}" EQUAL "")
  191. MESSAGE("Using OpenCV from " ${OpenCV_DIR})
  192. ENDIF (NOT "${OpenCV_DIR}" EQUAL "")
  193.  
  194. find_package(OpenCV)
  195. include_directories(${OpenCV_INCLUDE_DIRS})
  196. link_directories(${OpenCV_LIBRARY_DIRS})
  197.  
  198. #############################
  199. # Eigen ####################
  200. #############################
  201. find_package(Eigen REQUIRED)
  202. #include_directories(${EIGEN_INCLUDE_DIRS})
  203. include_directories(${Eigen_INCLUDE_DIRS})
  204. add_definitions(${EIGEN_DEFINITIONS})
  205.  
  206. find_package(cmake_modules REQUIRED)
  207.  
  208.  
  209. ##############################################################################
  210. # Some QT Magic (MOC Creation)
  211. ##############################################################################
  212.  
  213. file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
  214. file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
  215. file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/local/*.hpp src/qtros.h src/openni_listener.h src/qt_gui.h src/graph_manager.h src/glviewer.h src/ros_service_ui.h)
  216.  
  217. QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
  218. QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
  219. QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC} OPTIONS -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  220. #QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
  221.  
  222. ##############################################################################
  223. # Sources to Compile
  224. ##############################################################################
  225. SET(ADDITIONAL_SOURCES src/gicp-fallback.cpp src/main.cpp src/qtros.cpp src/openni_listener.cpp src/qt_gui.cpp src/node.cpp src/glviewer.cpp src/parameter_server.cpp src/ros_service_ui.cpp src/misc.cpp src/landmark.cpp src/loop_closing.cpp src/ColorOctomapServer.cpp src/scoped_timer.cpp src/icp.cpp src/matching_result.cpp)
  226. #GraphManager Files
  227. SET(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} src/graph_manager.cpp src/graph_mgr_io.cpp src/graph_manager2.cpp src/graph_mgr_odom.cpp)
  228. SET(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} src/transformation_estimation_euclidean.cpp src/transformation_estimation.cpp src/graph_manager2.cpp src/header.cpp)
  229. #Computation of meaningful covariances
  230. SET(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} src/covariance_estimation.cpp) # src/edge_labeler.cpp)
  231. #Detector Threshold Adapter
  232. SET(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} src/feature_adjuster.cpp src/aorb.cpp src/features.cpp)
  233.  
  234. IF (${USE_SIFT_GPU})
  235. SET(ADDITIONAL_SOURCES ${ADDITIONAL_SOURCES} src/sift_gpu_wrapper.cpp)
  236. ENDIF (${USE_SIFT_GPU})
  237.  
  238. file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS)
  239.  
  240. include_directories(external/ /usr/include/suitesparse/)
  241.  
  242. ##############################################################################
  243. # Binaries
  244. ##############################################################################
  245. add_executable(rgbdslam ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP} ${ADDITIONAL_SOURCES})
  246. add_dependencies(rgbdslam rgbdslam_gencpp)
  247.  
  248.  
  249.  
  250. #set libs
  251. #SET(G2O_LIBS cholmod g2o_core g2o_stuff g2o_types_slam3d g2o_solver_cholmod g2o_solver_pcg g2o_solver_csparse cxsparse g2o_incremental)
  252. #SET(G2O_LIBS ${G2O_LIBRARIES} cholmod cxsparse)
  253. #SET(LIBS_LINK GL GLU -lgl2ps ${G2O_LIBS} ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${OpenCV_LIBS})
  254. #Use specific version of cxsparse, to avoid linker warning about possible conflicts between versions 2.2.3 (linked from g2o) and 3.1.0
  255. SET(LIBS_LINK GL GLU cholmod cxsparse ${G2O_LIBRARIES} ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${OpenCV_LIBS})
  256. #-lboost_signals -lrt -loctomap -loctomap_server -loctomath)
  257.  
  258. IF (${USE_SIFT_GPU})
  259. SET(LIBS_LINK ${LIBS_LINK} siftgpu)
  260. ENDIF (${USE_SIFT_GPU})
  261. IF (${USE_GL2PS})
  262. SET(LIBS_LINK ${LIBS_LINK} -lgl2ps)
  263. ENDIF (${USE_GL2PS})
  264. IF (${USE_GICP})
  265. SET(LIBS_LINK ${LIBS_LINK} gicp ANN gsl gslcblas)
  266. ENDIF (${USE_GICP})
  267. #link libraries
  268. target_link_libraries(rgbdslam ${LIBS_LINK} ${catkin_LIBRARIES} ${Eigen_LIBRARIES})
  269.  
  270. IF (${USE_GICP})
  271. set(ROS_COMPILE_FLAGS ${ROS_COMPILE_FLAGS} -fpermissive)
  272. add_library(gicp external/gicp/bfgs_funcs.cpp external/gicp/gicp.cpp external/gicp/optimize.cpp external/gicp/scan.cpp external/gicp/transform.cpp)
  273. ENDIF (${USE_GICP})
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286. ###############################################################################
  287. ## Bag Viewer
  288. ###############################################################################
  289. #
  290. #file(GLOB QT_FORMS2 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
  291. #file(GLOB QT_RESOURCES2 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
  292. #file(GLOB_RECURSE QT_MOC2 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/local/*.hpp src/qtros.h src/bagloader.h src/qt_gui.h src/glviewer.h)
  293. #
  294. #QT4_ADD_RESOURCES(QT_RESOURCES_CPP2 ${QT_RESOURCES2})
  295. #QT4_WRAP_UI(QT_FORMS_HPP2 ${QT_FORMS2})
  296. #QT4_WRAP_CPP(QT_MOC_HPP2 ${QT_MOC2})
  297. #
  298. #
  299. #SET(ADDITIONAL_SOURCES2 src/result-bag-viewer.cpp src/bagloader.cpp src/qtros.cpp src/qt_gui.cpp src/glviewer.cpp src/parameter_server.cpp src/misc.cpp src/ColorOctomapServer.cpp src/scoped_timer.cpp)
  300. #add_executable(bagviewer ${QT_SOURCES2} ${QT_RESOURCES_CPP2} ${QT_FORMS_HPP2} ${QT_MOC_HPP2} ${ADDITIONAL_SOURCES2})
  301. #target_link_libraries(bagviewer ${LIBS_LINK})
  302. #
RAW Paste Data