|
| 1 | +cmake_minimum_required(VERSION 3.5) |
| 2 | +project(consai2r2_protobuf) |
| 3 | + |
| 4 | +# Default to C++14 |
| 5 | +if(NOT CMAKE_CXX_STANDARD) |
| 6 | + set(CMAKE_CXX_STANDARD 14) |
| 7 | +endif() |
| 8 | + |
| 9 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 10 | + add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) |
| 11 | +endif() |
| 12 | + |
| 13 | +# find dependencies |
| 14 | +find_package(ament_cmake REQUIRED) |
| 15 | +find_package(Protobuf REQUIRED) |
| 16 | +find_package(python_cmake_module REQUIRED) |
| 17 | + |
| 18 | +set(_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}") |
| 19 | + |
| 20 | +if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 21 | + set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}") |
| 22 | +endif() |
| 23 | + |
| 24 | +ament_python_install_package(${PROJECT_NAME}) |
| 25 | + |
| 26 | +# Protobuf |
| 27 | +include_directories( |
| 28 | + ${PROTOBUF_INCLUDE_DIRS} |
| 29 | +) |
| 30 | + |
| 31 | +set(protobuf_files |
| 32 | + proto/messages_robocup_ssl_wrapper.proto |
| 33 | + proto/messages_robocup_ssl_geometry.proto |
| 34 | + proto/messages_robocup_ssl_detection.proto |
| 35 | + proto/messages_robocup_ssl_robot_status.proto |
| 36 | + proto/messages_robocup_ssl_refbox_log.proto |
| 37 | + proto/referee.proto |
| 38 | + proto/game_event.proto |
| 39 | + proto/grSim_Replacement.proto |
| 40 | + proto/grSim_Commands.proto |
| 41 | + proto/grSim_Packet.proto |
| 42 | +) |
| 43 | + |
| 44 | +protobuf_generate_cpp(PROTO_CPP PROTO_H |
| 45 | + ${protobuf_files} |
| 46 | +) |
| 47 | + |
| 48 | +include_directories(include ${CMAKE_CURRENT_BINARY_DIR}) |
| 49 | + |
| 50 | +add_library(consai2r2_protobuf |
| 51 | + SHARED ${PROTO_CPP} ${PROTO_H} |
| 52 | +) |
| 53 | + |
| 54 | +target_link_libraries(consai2r2_protobuf ${PROTOBUF_LIBRARIES}) |
| 55 | + |
| 56 | +protobuf_generate_python(PROTO_PY |
| 57 | + ${protobuf_files} |
| 58 | +) |
| 59 | + |
| 60 | +add_custom_target(consai2r2_protobuf_py ALL DEPENDS ${PROTO_PY}) |
| 61 | + |
| 62 | +install( |
| 63 | + FILES ${PROTO_H} |
| 64 | + DESTINATION include/${PROJECT_NAME}) |
| 65 | + |
| 66 | +install( |
| 67 | + TARGETS consai2r2_protobuf |
| 68 | + ARCHIVE DESTINATION lib |
| 69 | + LIBRARY DESTINATION lib) |
| 70 | + |
| 71 | +install(FILES ${PROTO_PY} |
| 72 | + DESTINATION "${PYTHON_INSTALL_DIR}") |
| 73 | + |
| 74 | +ament_export_include_directories(include) |
| 75 | +ament_export_libraries(consai2r2_protobuf) |
| 76 | +ament_export_dependencies(ament_cmake) |
| 77 | +ament_export_dependencies(Protobuf) |
| 78 | +ament_export_dependencies(python_cmake_module) |
| 79 | + |
| 80 | + |
| 81 | +if(BUILD_TESTING) |
| 82 | + find_package(ament_lint_auto REQUIRED) |
| 83 | + # the following line skips the linter which checks for copyrights |
| 84 | + # uncomment the line when a copyright and license is not present in all source files |
| 85 | + #set(ament_cmake_copyright_FOUND TRUE) |
| 86 | + # the following line skips cpplint (only works in a git repo) |
| 87 | + # uncomment the line when this package is not in a git repo |
| 88 | + #set(ament_cmake_cpplint_FOUND TRUE) |
| 89 | + ament_lint_auto_find_test_dependencies() |
| 90 | +endif() |
| 91 | + |
| 92 | +ament_package() |
0 commit comments