2014-08-14 15:05:25 -07:00
#
# Get the package name of the default ROS middleware implemenation.
#
# Either selcting it using the variable ROS_MIDDLEWARE_IMPLEMENTATION or
# choosing a default from the available implementations.
#
# :param var: the output variable name containing the package name
# :type var: string
#
2015-03-04 16:31:22 -08:00
function ( get_default_rmw_implementation var )
get_available_rmw_implementations ( middleware_implementations )
2014-08-14 15:05:25 -07:00
2014-09-13 10:20:50 -07:00
if ( "${middleware_implementations} " STREQUAL " " )
2014-08-14 15:05:25 -07:00
message ( FATAL_ERROR "Could not find any ROS middleware implementation." )
endif ( )
# option()
2014-09-13 10:20:50 -07:00
if ( NOT "${ROS_MIDDLEWARE_IMPLEMENTATION} " STREQUAL " " )
2014-08-14 15:05:25 -07:00
set ( middleware_implementation "${ROS_MIDDLEWARE_IMPLEMENTATION}" )
2014-09-13 10:20:50 -07:00
elseif ( NOT "$ENV{ROS_MIDDLEWARE_IMPLEMENTATION} " STREQUAL " " )
2014-08-14 15:05:25 -07:00
set ( middleware_implementation "$ENV{ROS_MIDDLEWARE_IMPLEMENTATION}" )
else ( )
# TODO detemine "default" implementation based on the available ones
list ( GET middleware_implementations 0 middleware_implementation )
endif ( )
# verify that the selection one is available
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 ( )
find_package ( "${middleware_implementation}" REQUIRED )
# persist implementation decision in cache
set (
R O S _ M I D D L E W A R E _ I M P L E M E N T A T I O N " $ { m i d d l e w a r e _ i m p l e m e n t a t i o n } "
C A C H E S T R I N G " S e l e c t R O S m i d d l e w a r e i m p l e m e n t a t i o n t o l i n k a g a i n s t " F O R C E
)
set ( ${ var } ${ middleware_implementation } PARENT_SCOPE )
endfunction ( )