From fee3118bdd79467b6d9306e0b9d3d520549a32d0 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 5 Jan 2017 12:13:58 -0800 Subject: [PATCH 1/2] use rmw implementation --- rclcpp/CMakeLists.txt | 42 +++++++++++++---------------- rclcpp/package.xml | 2 +- rclcpp_lifecycle/CMakeLists.txt | 48 ++++++++++++++------------------- rclcpp_lifecycle/package.xml | 1 - 4 files changed, 39 insertions(+), 54 deletions(-) diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index 849031c..d145422 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -7,7 +7,6 @@ find_package(rcl REQUIRED) find_package(rcl_interfaces REQUIRED) find_package(rmw REQUIRED) find_package(rmw_implementation REQUIRED) -find_package(rmw_implementation_cmake REQUIRED) find_package(rosidl_generator_cpp REQUIRED) find_package(rosidl_typesupport_c REQUIRED) find_package(rosidl_typesupport_cpp REQUIRED) @@ -54,31 +53,24 @@ set(${PROJECT_NAME}_SRCS src/rclcpp/utilities.cpp ) -macro(target) - if(NOT target_suffix STREQUAL "") - get_rcl_information("${rmw_implementation}" "rcl${target_suffix}") - endif() - add_library(${PROJECT_NAME}${target_suffix} SHARED - ${${PROJECT_NAME}_SRCS}) - ament_target_dependencies(${PROJECT_NAME}${target_suffix} - "rcl${target_suffix}" - "rosidl_generator_cpp" - "rosidl_typesupport_cpp") +add_library(${PROJECT_NAME} SHARED + ${${PROJECT_NAME}_SRCS}) +ament_target_dependencies(${PROJECT_NAME} + "rcl" + "rosidl_generator_cpp" + "rosidl_typesupport_cpp") - # Causes the visibility macros to use dllexport rather than dllimport, - # which is appropriate when building the dll but not consuming it. - target_compile_definitions(${PROJECT_NAME}${target_suffix} - PRIVATE "RCLCPP_BUILDING_LIBRARY") +# Causes the visibility macros to use dllexport rather than dllimport, +# which is appropriate when building the dll but not consuming it. +target_compile_definitions(${PROJECT_NAME} + PRIVATE "RCLCPP_BUILDING_LIBRARY") - install( - TARGETS ${PROJECT_NAME}${target_suffix} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ) -endmacro() - -call_for_each_rmw_implementation(target GENERATE_DEFAULT) +install( + TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) ament_export_dependencies(ament_cmake) ament_export_dependencies(rcl) @@ -94,6 +86,8 @@ if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() + find_package(rmw_implementation_cmake REQUIRED) + ament_add_gtest(test_function_traits test/test_function_traits.cpp) if(TARGET test_function_traits) target_include_directories(test_function_traits PUBLIC diff --git a/rclcpp/package.xml b/rclcpp/package.xml index 9e66502..5f03209 100644 --- a/rclcpp/package.xml +++ b/rclcpp/package.xml @@ -12,7 +12,6 @@ rmw rcl_interfaces - rmw_implementation_cmake rosidl_generator_cpp rosidl_typesupport_c rosidl_typesupport_cpp @@ -30,6 +29,7 @@ ament_lint_auto ament_lint_common rmw + rmw_implementation_cmake ament_cmake diff --git a/rclcpp_lifecycle/CMakeLists.txt b/rclcpp_lifecycle/CMakeLists.txt index 2da6eb1..e74b3ec 100644 --- a/rclcpp_lifecycle/CMakeLists.txt +++ b/rclcpp_lifecycle/CMakeLists.txt @@ -10,41 +10,33 @@ endif() find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rcl_lifecycle REQUIRED) -find_package(rmw_implementation_cmake REQUIRED) find_package(std_msgs REQUIRED) find_package(lifecycle_msgs REQUIRED) include_directories(include) -macro(targets) - get_rclcpp_information("${rmw_implementation}" "rclcpp${target_suffix}") - get_rcl_lifecycle_information("${rmw_implementation}" "rcl_lifecycle${target_suffix}") +### CPP High level library +add_library(rclcpp_lifecycle + SHARED + src/lifecycle_node.cpp + src/node_interfaces/lifecycle_node_interface.cpp + src/state.cpp + src/transition.cpp +) +ament_target_dependencies(rclcpp_lifecycle + "lifecycle_msgs" + "rcl_lifecycle" + "rclcpp") - ### CPP High level library - add_library(rclcpp_lifecycle${target_suffix} - SHARED - src/lifecycle_node.cpp - src/node_interfaces/lifecycle_node_interface.cpp - src/state.cpp - src/transition.cpp - ) - ament_target_dependencies(rclcpp_lifecycle${target_suffix} - "lifecycle_msgs" - "rcl_lifecycle${target_suffix}" - "rclcpp${target_suffix}") +# Causes the visibility macros to use dllexport rather than dllimport, +# which is appropriate when building the dll but not consuming it. +target_compile_definitions(rclcpp_lifecycle PRIVATE "RCLCPP_LIFECYCLE_BUILDING_DLL") - # Causes the visibility macros to use dllexport rather than dllimport, - # which is appropriate when building the dll but not consuming it. - target_compile_definitions(rclcpp_lifecycle${target_suffix} PRIVATE "RCLCPP_LIFECYCLE_BUILDING_DLL") - - install(TARGETS - rclcpp_lifecycle${target_suffix} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -endmacro() - -call_for_each_rmw_implementation(targets GENERATE_DEFAULT) +install(TARGETS + rclcpp_lifecycle + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) diff --git a/rclcpp_lifecycle/package.xml b/rclcpp_lifecycle/package.xml index 7eea88c..ebb1858 100644 --- a/rclcpp_lifecycle/package.xml +++ b/rclcpp_lifecycle/package.xml @@ -13,7 +13,6 @@ rclcpp rcl_lifecycle rmw_implementation - rmw_implementation_cmake rosidl_default_generators std_msgs lifecycle_msgs From 78dfef75b4687e06885780c878895e6c54b0baed Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 6 Jan 2017 15:46:08 -0800 Subject: [PATCH 2/2] remove obsolete CMake functions --- rclcpp/cmake/get_rclcpp_information.cmake | 93 ----------------------- rclcpp/rclcpp-extras.cmake | 1 - 2 files changed, 94 deletions(-) delete mode 100644 rclcpp/cmake/get_rclcpp_information.cmake diff --git a/rclcpp/cmake/get_rclcpp_information.cmake b/rclcpp/cmake/get_rclcpp_information.cmake deleted file mode 100644 index 0eb00ad..0000000 --- a/rclcpp/cmake/get_rclcpp_information.cmake +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Get all information about rclcpp for a specific RMW implementation. -# -# It sets the common variables _DEFINITIONS, _INCLUDE_DIRS and _LIBRARIES -# with the given prefix. -# -# :param rmw_implementation: the RMW implementation name -# :type rmw_implementation: string -# :param var_prefix: the prefix of all output variable names -# :type var_prefix: string -# -macro(get_rclcpp_information rmw_implementation var_prefix) - # pretend to be a "package" - # so that the variables can be used by various functions / macros - set(${var_prefix}_FOUND TRUE) - - # Get rcl using the existing macro - if(NOT target_suffix STREQUAL "") - get_rcl_information("${rmw_implementation}" "rcl${target_suffix}") - endif() - - # include directories - normalize_path(${var_prefix}_INCLUDE_DIRS - "${rclcpp_DIR}/../../../include") - - # libraries - set(_libs) - # search for library relative to this CMake file - set(_library_target "rclcpp") - get_available_rmw_implementations(_rmw_impls) - list(LENGTH _rmw_impls _rmw_impls_length) - if(_rmw_impls_length GREATER 1) - set(_library_target "${_library_target}__${rmw_implementation}") - endif() - set(_lib "NOTFOUND") - find_library( - _lib NAMES "${_library_target}" - PATHS "${rclcpp_DIR}/../../../lib" - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - ) - if(NOT _lib) - # warn about not existing library and ignore it - message(WARNING "Package 'rclcpp' doesn't contain the library '${_library_target}'") - elseif(NOT IS_ABSOLUTE "${_lib}") - # the found library must be an absolute path - message(FATAL_ERROR "Package 'rclcpp' found the library '${_library_target}' at '${_lib}' which is not an absolute path") - elseif(NOT EXISTS "${_lib}") - # the found library must exist - message(FATAL_ERROR "Package 'rclcpp' found the library '${_lib}' which doesn't exist") - else() - list(APPEND _libs "${_lib}") - endif() - - # dependencies - set(_exported_dependencies - "rcl_interfaces" - "rcl${target_suffix}" - "rosidl_generator_cpp" - "rosidl_typesupport_cpp") - set(${var_prefix}_DEFINITIONS) - foreach(_dep ${_exported_dependencies}) - if(NOT ${_dep}_FOUND) - find_package("${_dep}" QUIET REQUIRED) - endif() - if(${_dep}_DEFINITIONS) - list_append_unique(${var_prefix}_DEFINITIONS "${${_dep}_DEFINITIONS}") - endif() - if(${_dep}_INCLUDE_DIRS) - list_append_unique(${var_prefix}_INCLUDE_DIRS "${${_dep}_INCLUDE_DIRS}") - endif() - if(${_dep}_LIBRARIES) - list(APPEND _libs "${${_dep}_LIBRARIES}") - endif() - endforeach() - if(_libs) - ament_libraries_deduplicate(_libs "${_libs}") - endif() - set(${var_prefix}_LIBRARIES "${_libs}") -endmacro() diff --git a/rclcpp/rclcpp-extras.cmake b/rclcpp/rclcpp-extras.cmake index facb37c..7d3a142 100644 --- a/rclcpp/rclcpp-extras.cmake +++ b/rclcpp/rclcpp-extras.cmake @@ -25,6 +25,5 @@ macro(_rclcpp_register_package_hook) endif() endmacro() -include("${rclcpp_DIR}/get_rclcpp_information.cmake") include("${rclcpp_DIR}/rclcpp_create_node_main.cmake") include("${rclcpp_DIR}/rclcpp_register_node_plugins.cmake")