From c6c04749ca4076466f6d7e16021168e62c73f166 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 8 Aug 2014 16:57:41 -0700 Subject: [PATCH] choose default middleware implementation from available ones --- rclcpp/rclcpp-extras.cmake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rclcpp/rclcpp-extras.cmake b/rclcpp/rclcpp-extras.cmake index 8f428c5..2b63a1d 100644 --- a/rclcpp/rclcpp-extras.cmake +++ b/rclcpp/rclcpp-extras.cmake @@ -1,22 +1,26 @@ # copied from rclcpp/rclcpp-extras.cmake -# option() +ament_index_get_resources(_middleware_implementations "ros_middleware_implementation") +if("${_middleware_implementations}" STREQUAL "") + message(FATAL_ERROR "Could not find any ROS middleware implementation.") +endif() + set(_middleware_implementation "") +# option() if(NOT "${ROS_MIDDLEWARE_IMPLEMENTATION}" STREQUAL "") set(_middleware_implementation "${ROS_MIDDLEWARE_IMPLEMENTATION}") elseif(NOT "$ENV{ROS_MIDDLEWARE_IMPLEMENTATION}" STREQUAL "") set(_middleware_implementation "$ENV{ROS_MIDDLEWARE_IMPLEMENTATION}") else() - # detemine "default" implementation based on the available ones - set(_middleware_implementation "ros_middleware_connext_cpp") - if("${_middleware_implementation}" STREQUAL "") - message(FATAL_ERROR "No middleware implementation available.") - endif() + # TODO detemine "default" implementation based on the available ones + list(GET _middleware_implementations 1 _middleware_implementation) endif() -message("rclcpp_DEFINITIONS ${rclcpp_DEFINITIONS}") -message("rclcpp_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS}") -message("rclcpp_LIBRARIES ${rclcpp_LIBRARIES}") +list(FIND _middleware_implementations "${_middleware_implementation}" _index) +if(_index EQUAL -1) + string(REPLACE ";" ", " _middleware_implementations_string "${_middleware_implementations}") + message(FATAL_ERROR "Could not find ROS middleware implementation '${_middleware_implementation}'. Choose one of the following: ${_middleware_implementations_string}") +endif() message(STATUS "Using middleware implementation: ${_middleware_implementation}") find_package("${_middleware_implementation}" REQUIRED) @@ -30,7 +34,3 @@ set( list(APPEND rclcpp_DEFINITIONS ${${ROS_MIDDLEWARE_IMPLEMENTATION}_DEFINITIONS}) list(APPEND rclcpp_INCLUDE_DIRS ${${ROS_MIDDLEWARE_IMPLEMENTATION}_INCLUDE_DIRS}) list(APPEND rclcpp_LIBRARIES ${${ROS_MIDDLEWARE_IMPLEMENTATION}_LIBRARIES}) - -message("rclcpp_DEFINITIONS ${rclcpp_DEFINITIONS}") -message("rclcpp_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS}") -message("rclcpp_LIBRARIES ${rclcpp_LIBRARIES}")