CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # Copyright 2016 The Cartographer Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. cmake_minimum_required(VERSION 2.8.12) # Ships with Ubuntu 14.04 (Trusty)
  15. project(cartographer_rviz)
  16. set(PACKAGE_DEPENDENCIES
  17. cartographer_ros
  18. cartographer_ros_msgs
  19. eigen_conversions
  20. message_runtime
  21. roscpp
  22. roslib
  23. rviz
  24. )
  25. if(WIN32)
  26. set(Boost_USE_STATIC_LIBS FALSE)
  27. endif()
  28. find_package(Boost REQUIRED COMPONENTS system iostreams)
  29. find_package(cartographer REQUIRED)
  30. include("${CARTOGRAPHER_CMAKE_DIR}/functions.cmake")
  31. google_initialize_cartographer_project()
  32. find_package(Abseil REQUIRED)
  33. find_package(Eigen3 REQUIRED)
  34. find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES})
  35. catkin_package(
  36. CATKIN_DEPENDS
  37. message_runtime
  38. ${PACKAGE_DEPENDENCIES}
  39. INCLUDE_DIRS "."
  40. )
  41. file(GLOB_RECURSE ALL_SRCS "cartographer_rviz/*.cc" "cartographer_rviz/*.h")
  42. set(CMAKE_AUTOMOC ON)
  43. if(rviz_QT_VERSION VERSION_LESS "5")
  44. message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  45. find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
  46. include(${QT_USE_FILE})
  47. else()
  48. message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  49. find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
  50. set(QT_LIBRARIES Qt5::Core Qt5::Widgets)
  51. include_directories(${Qt5Widgets_INCLUDE_DIRS})
  52. endif()
  53. add_definitions(-DQT_NO_KEYWORDS)
  54. add_library(${PROJECT_NAME} ${ALL_SRCS})
  55. target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
  56. # Add the binary directory first, so that port.h is included after it has
  57. # been generated.
  58. target_include_directories(${PROJECT_NAME} PUBLIC
  59. $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
  60. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
  61. $<INSTALL_INTERFACE:include>
  62. )
  63. target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
  64. "${EIGEN3_INCLUDE_DIR}")
  65. target_link_libraries(${PROJECT_NAME} PUBLIC ${EIGEN3_LIBRARIES})
  66. target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
  67. "${Boost_INCLUDE_DIRS}")
  68. target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
  69. target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
  70. target_link_libraries(${PROJECT_NAME} PUBLIC ${catkin_LIBRARIES})
  71. add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
  72. set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}")
  73. set_target_properties(${PROJECT_NAME} PROPERTIES
  74. COMPILE_FLAGS ${TARGET_COMPILE_FLAGS})
  75. target_link_libraries(${PROJECT_NAME} PUBLIC cartographer)
  76. # On windows, rviz won't find the DLL in CATKIN_PACKAGE_BIN_DESTINATION,
  77. # but it will in CATKIN_PACKAGE_LIB_DESTINATION?
  78. if(WIN32)
  79. set(RUNTIME_DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
  80. else()
  81. set(RUNTIME_DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
  82. endif()
  83. install(TARGETS ${PROJECT_NAME}
  84. ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  85. LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  86. RUNTIME DESTINATION ${RUNTIME_DESTINATION}
  87. )
  88. install(FILES rviz_plugin_description.xml
  89. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  90. )
  91. install(DIRECTORY ogre_media
  92. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  93. )