From 157a487fbbaed5ea56a5d2d30ef13dcb254b6bd1 Mon Sep 17 00:00:00 2001 From: Jose Antonio Moral Date: Tue, 21 Jul 2020 17:11:43 +0200 Subject: [PATCH] Release micro-ROS Foxy (#1) * Fix exporting for static library. * Add ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT compile definition. * Handle rcpputils in case of single typesupport. Co-authored-by: julibert --- rosidl_typesupport_c/CMakeLists.txt | 20 ++++++++++++++++--- ...dl_typesupport_c_generate_interfaces.cmake | 4 +++- .../src/type_support_dispatch.hpp | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/rosidl_typesupport_c/CMakeLists.txt b/rosidl_typesupport_c/CMakeLists.txt index c519c2e1..4ae09919 100644 --- a/rosidl_typesupport_c/CMakeLists.txt +++ b/rosidl_typesupport_c/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5) project(rosidl_typesupport_c) +option(ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT "Enable single typesupport" ON) + # Default to C11 if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 11) @@ -16,12 +18,16 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() find_package(ament_cmake_ros REQUIRED) -find_package(rcpputils REQUIRED) find_package(rosidl_runtime_c REQUIRED) +if(NOT ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT) + find_package(rcpputils REQUIRED) +endif() -ament_export_dependencies(rcpputils) ament_export_dependencies(rosidl_runtime_c) ament_export_dependencies(rosidl_typesupport_interface) +if(NOT ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT) + ament_export_dependencies(rcpputils) +endif() ament_export_include_directories(include) @@ -36,14 +42,22 @@ if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE "ROSIDL_TYPESUPPORT_C_BUILDING_DLL") endif() +target_compile_definitions(${PROJECT_NAME} + PRIVATE + $<$:ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT> + ) target_include_directories(${PROJECT_NAME} PUBLIC "$" "$") ament_target_dependencies(${PROJECT_NAME} - "rcpputils" "rosidl_runtime_c" ) +if(NOT ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT) + ament_target_dependencies(${PROJECT_NAME} + "rcpputils" + ) +endif() ament_export_libraries(${PROJECT_NAME}) ament_export_targets(${PROJECT_NAME}) diff --git a/rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake b/rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake index c02ffddd..ffa6727d 100644 --- a/rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake +++ b/rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake @@ -155,7 +155,9 @@ add_dependencies( if(NOT rosidl_generate_interfaces_SKIP_INSTALL) install( - TARGETS ${rosidl_generate_interfaces_TARGET}${_target_suffix} + TARGETS + ${rosidl_generate_interfaces_TARGET}${_target_suffix} + ${rosidl_generate_interfaces_TARGET}__${typesupports} EXPORT ${rosidl_generate_interfaces_TARGET}${_target_suffix} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib diff --git a/rosidl_typesupport_c/src/type_support_dispatch.hpp b/rosidl_typesupport_c/src/type_support_dispatch.hpp index 188fbefa..ab273d5a 100644 --- a/rosidl_typesupport_c/src/type_support_dispatch.hpp +++ b/rosidl_typesupport_c/src/type_support_dispatch.hpp @@ -24,8 +24,10 @@ #include #include +#ifndef ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT #include "rcpputils/find_library.hpp" #include "rcpputils/shared_library.hpp" +#endif // ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT #include "rosidl_typesupport_c/identifier.h" #include "rosidl_typesupport_c/type_support_map.h" @@ -43,6 +45,7 @@ get_typesupport_handle_function( return handle; } +#ifndef ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT if (handle->typesupport_identifier == rosidl_typesupport_c__typesupport_identifier) { const type_support_map_t * map = \ static_cast(handle->data); @@ -90,6 +93,8 @@ get_typesupport_handle_function( return ts; } } +#endif // ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT + return nullptr; }