Skip to content

Commit

Permalink
Release micro-ROS Foxy (#1)
Browse files Browse the repository at this point in the history
* Fix exporting for static library.

* Add ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT compile definition.

* Handle rcpputils in case of single typesupport.

Co-authored-by: julibert <[email protected]>
  • Loading branch information
pablogs9 and julibert committed Jan 12, 2021
1 parent 7de7db9 commit c0a29ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
20 changes: 17 additions & 3 deletions rosidl_typesupport_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -16,13 +18,17 @@ 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(rcutils 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)

Expand All @@ -37,15 +43,23 @@ if(WIN32)
target_compile_definitions(${PROJECT_NAME}
PRIVATE "ROSIDL_TYPESUPPORT_C_BUILDING_DLL")
endif()
target_compile_definitions(${PROJECT_NAME}
PRIVATE
$<$<BOOL:${ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT}>:ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT>
)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

ament_target_dependencies(${PROJECT_NAME}
"rcpputils"
"rcutils"
"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})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions rosidl_typesupport_c/src/type_support_dispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
#include <list>
#include <string>

#ifndef ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT
#include "rcpputils/find_library.hpp"
#include "rcpputils/shared_library.hpp"
#endif // ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT
#include "rcutils/error_handling.h"
#include "rosidl_typesupport_c/identifier.h"
#include "rosidl_typesupport_c/type_support_map.h"
Expand All @@ -44,6 +46,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<const type_support_map_t *>(handle->data);
Expand Down Expand Up @@ -116,6 +119,8 @@ get_typesupport_handle_function(
RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING(
"Handle's typesupport identifier (%s) is not supported by this library\n",
handle->typesupport_identifier);
#endif // ROSIDL_TYPESUPPORT_SINGLE_TYPESUPPORT

return nullptr;
}

Expand Down

0 comments on commit c0a29ae

Please sign in to comment.