|
| 1 | +cmake_minimum_required(VERSION 3.17) |
| 2 | +project(rviz_python_bindings) |
| 3 | + |
| 4 | +set(shiboken_qt_components |
| 5 | + QtCore |
| 6 | + QtGui |
| 7 | + QtWidgets |
| 8 | +) |
| 9 | + |
| 10 | +find_package(ament_cmake REQUIRED) |
| 11 | +find_package(ament_cmake_python REQUIRED) |
| 12 | +find_package(python_qt_binding REQUIRED) |
| 13 | +include(${python_qt_binding_DIR}/shiboken_helper.cmake) #${CMAKE_CURRENT_SOURCE_DIR}/../../python_qt_binding/cmake/shiboken_helper.cmake)# |
| 14 | +find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets) |
| 15 | +find_package(rviz_common REQUIRED) |
| 16 | +find_package(Python3 COMPONENTS Development) |
| 17 | + |
| 18 | +# name of the library to be generated by shiboken |
| 19 | +set(shiboken_bindings_library "rviz_shiboken") |
| 20 | +# path to the include wrapper used by shiboken for generation |
| 21 | +set(shiboken_include_wrapper "${CMAKE_CURRENT_SOURCE_DIR}/conf/global.hpp") |
| 22 | +# path to the typesystem file used by shiboken for generation |
| 23 | +set(shiboken_typesystem "${CMAKE_CURRENT_SOURCE_DIR}/conf/typesystem.xml") |
| 24 | +# sources generated by shiboken depends on typesystem |
| 25 | +set(shiboken_generated_sources |
| 26 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_shiboken_module_wrapper.cpp |
| 27 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_wrapper.cpp |
| 28 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_visualizerframepy_wrapper.cpp |
| 29 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_yamlconfigreader_wrapper.cpp |
| 30 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_yamlconfigwriter_wrapper.cpp |
| 31 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_config_wrapper.cpp |
| 32 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_config_mapiterator_wrapper.cpp |
| 33 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_visualizationframe_wrapper.cpp |
| 34 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_visualizationmanager_wrapper.cpp |
| 35 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_displaygroup_wrapper.cpp |
| 36 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_display_wrapper.cpp |
| 37 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_viewmanager_wrapper.cpp |
| 38 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_paneldockwidget_wrapper.cpp |
| 39 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_tool_wrapper.cpp |
| 40 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_toolmanager_wrapper.cpp |
| 41 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_properties_wrapper.cpp |
| 42 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_properties_property_wrapper.cpp |
| 43 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_properties_boolproperty_wrapper.cpp |
| 44 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_common_viewcontroller_wrapper.cpp |
| 45 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_rendering_ogrelogging_wrapper.cpp |
| 46 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/rviz_rendering_wrapper.cpp |
| 47 | + ${CMAKE_CURRENT_BINARY_DIR}/${shiboken_bindings_library}/ogre_wrapper.cpp |
| 48 | +) |
| 49 | + |
| 50 | +ament_get_recursive_properties(deps_include_dirs _ ${rviz_common_TARGETS}) |
| 51 | +list(APPEND shiboken_include_dirs |
| 52 | + ${deps_include_dirs}) |
| 53 | +message(STATUS "ROS inlcude dirs: ${deps_include_dirs}") |
| 54 | +message(STATUS "QT5 inlcude dirs: ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS}") |
| 55 | +list(APPEND shiboken_include_dirs |
| 56 | + ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} |
| 57 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 58 | + $<INSTALL_INTERFACE:include> |
| 59 | +) |
| 60 | + |
| 61 | +add_library(rviz_python SHARED |
| 62 | + src/visualizer_frame_py.cpp |
| 63 | +) |
| 64 | + |
| 65 | +target_include_directories(rviz_python PUBLIC |
| 66 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 67 | + $<INSTALL_INTERFACE:include>) |
| 68 | +target_compile_options(rviz_python PUBLIC -Wl,--no-undefined) |
| 69 | +ament_target_dependencies(rviz_python |
| 70 | + rviz_common |
| 71 | + Qt5 |
| 72 | +) |
| 73 | + |
| 74 | +install(TARGETS rviz_python |
| 75 | + EXPORT export_rviz_python |
| 76 | + ARCHIVE DESTINATION lib |
| 77 | + LIBRARY DESTINATION lib |
| 78 | + RUNTIME DESTINATION bin |
| 79 | +) |
| 80 | + |
| 81 | + |
| 82 | +shiboken_generator_ext( |
| 83 | + "rviz_shiboken" # TARGET |
| 84 | + "${shiboken_include_wrapper}" # INCLUDE WRAPPER |
| 85 | + "${shiboken_typesystem}" # TYPSYSTEM |
| 86 | + "${CMAKE_CURRENT_BINARY_DIR}" # Working Directory |
| 87 | + "${shiboken_generated_sources}" # Generated Sources |
| 88 | + "${shiboken_include_dirs}" # INCLUDE DIRS |
| 89 | + "${CMAKE_CURRENT_BINARY_DIR}" # BUILD DIR |
| 90 | +) |
| 91 | + |
| 92 | +add_library( |
| 93 | + ${shiboken_bindings_library} MODULE |
| 94 | + ${shiboken_generated_sources}) |
| 95 | + |
| 96 | +shiboken_include_directories( |
| 97 | + ${shiboken_bindings_library} |
| 98 | + "${shiboken_qt_components}") |
| 99 | + |
| 100 | +target_include_directories( |
| 101 | + ${shiboken_bindings_library} PRIVATE |
| 102 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 103 | + $<INSTALL_INTERFACE:include> |
| 104 | + ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} |
| 105 | +) |
| 106 | + |
| 107 | +target_link_libraries( |
| 108 | + ${shiboken_bindings_library} |
| 109 | + Qt5::Core |
| 110 | + Qt5::Gui |
| 111 | + Qt5::Widgets |
| 112 | + rviz_python |
| 113 | +) |
| 114 | +ament_target_dependencies( |
| 115 | + ${shiboken_bindings_library} |
| 116 | + rviz_common |
| 117 | +) |
| 118 | +shiboken_target_link_libraries(${shiboken_bindings_library} ${shiboken_qt_components}) |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | +set_target_properties(${shiboken_bindings_library} PROPERTIES |
| 123 | +PREFIX "") |
| 124 | +set_property(TARGET ${shiboken_bindings_library} PROPERTY OUTPUT_NAME |
| 125 | +"${shiboken_bindings_library}.${Python3_SOABI}") |
| 126 | + |
| 127 | +if(WIN32) |
| 128 | + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 129 | + set_property(TARGET ${shiboken_bindings_library} PROPERTY SUFFIX "_d.pyd") |
| 130 | + else() |
| 131 | + set_property(TARGET ${shiboken_bindings_library} PROPERTY SUFFIX ".pyd") |
| 132 | + endif() |
| 133 | + target_link_libraries( |
| 134 | + ${shiboken_bindings_library} |
| 135 | + Python3_LIBRARIES |
| 136 | + ) |
| 137 | +endif() |
| 138 | + |
| 139 | +ament_python_install_package(rviz) |
| 140 | +install(TARGETS ${shiboken_bindings_library} |
| 141 | + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_DIR}/rviz |
| 142 | +) |
| 143 | + |
| 144 | + |
| 145 | +if(BUILD_TESTING) |
| 146 | + find_package(ament_lint_auto REQUIRED) |
| 147 | + find_package(ament_cmake_pytest REQUIRED) |
| 148 | + # the following line skips the linter which checks for copyrights |
| 149 | + # comment the line when a copyright and license is added to all source files |
| 150 | + set(ament_cmake_copyright_FOUND TRUE) |
| 151 | + # the following line skips cpplint (only works in a git repo) |
| 152 | + # comment the line when this package is in a git repo and when |
| 153 | + # a copyright and license is added to all source files |
| 154 | + set(ament_cmake_cpplint_FOUND TRUE) |
| 155 | + |
| 156 | + ament_lint_auto_find_test_dependencies() |
| 157 | +endif() |
| 158 | + |
| 159 | +ament_export_include_directories( |
| 160 | + include |
| 161 | +) |
| 162 | +ament_export_libraries( |
| 163 | + rviz_python |
| 164 | +) |
| 165 | +ament_export_targets( |
| 166 | + export_rviz_python |
| 167 | +) |
| 168 | + |
| 169 | +ament_package() |
0 commit comments