CMakeLists.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. message_runtime
  20. roscpp
  21. roslib
  22. rviz
  23. )
  24. if(WIN32)
  25. set(Boost_USE_STATIC_LIBS FALSE)
  26. endif()
  27. find_package(Boost REQUIRED COMPONENTS system iostreams)
  28. find_package(cartographer REQUIRED)
  29. include("${CARTOGRAPHER_CMAKE_DIR}/functions.cmake")
  30. google_initialize_cartographer_project()
  31. find_package(absl REQUIRED)
  32. find_package(Eigen3 REQUIRED)
  33. find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES})
  34. catkin_package(
  35. CATKIN_DEPENDS
  36. message_runtime
  37. ${PACKAGE_DEPENDENCIES}
  38. INCLUDE_DIRS "."
  39. )
  40. file(GLOB_RECURSE ALL_SRCS "cartographer_rviz/*.cc" "cartographer_rviz/*.h")
  41. set(CMAKE_AUTOMOC ON)
  42. if(rviz_QT_VERSION VERSION_LESS "5")
  43. message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  44. find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
  45. include(${QT_USE_FILE})
  46. else()
  47. message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
  48. find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
  49. set(QT_LIBRARIES Qt5::Core Qt5::Widgets)
  50. include_directories(${Qt5Widgets_INCLUDE_DIRS})
  51. endif()
  52. add_definitions(-DQT_NO_KEYWORDS)
  53. add_library(${PROJECT_NAME} ${ALL_SRCS})
  54. target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES})
  55. # Add the binary directory first, so that port.h is included after it has
  56. # been generated.
  57. target_include_directories(${PROJECT_NAME} PUBLIC
  58. $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
  59. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
  60. $<INSTALL_INTERFACE:include>
  61. )
  62. target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
  63. "${EIGEN3_INCLUDE_DIR}")
  64. target_link_libraries(${PROJECT_NAME} PUBLIC ${EIGEN3_LIBRARIES})
  65. target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
  66. "${Boost_INCLUDE_DIRS}")
  67. target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
  68. target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${catkin_INCLUDE_DIRS})
  69. target_link_libraries(${PROJECT_NAME} PUBLIC ${catkin_LIBRARIES})
  70. add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
  71. set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}")
  72. set_target_properties(${PROJECT_NAME} PROPERTIES
  73. COMPILE_FLAGS ${TARGET_COMPILE_FLAGS})
  74. target_link_libraries(${PROJECT_NAME} PUBLIC cartographer)
  75. # On windows, rviz won't find the DLL in CATKIN_PACKAGE_BIN_DESTINATION,
  76. # but it will in CATKIN_PACKAGE_LIB_DESTINATION?
  77. if(WIN32)
  78. set(RUNTIME_DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
  79. else()
  80. set(RUNTIME_DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
  81. endif()
  82. install(TARGETS ${PROJECT_NAME}
  83. ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  84. LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  85. RUNTIME DESTINATION ${RUNTIME_DESTINATION}
  86. )
  87. install(FILES rviz_plugin_description.xml
  88. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  89. )
  90. install(DIRECTORY ogre_media
  91. DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
  92. )