Skip to content

Commit

Permalink
add option to filter available RMW implementations (#199)
Browse files Browse the repository at this point in the history
* add option to filter available RMW implementations

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>

* rephrase message based on feedback

Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
  • Loading branch information
dirk-thomas authored Mar 8, 2020
1 parent 28f9185 commit 71b000c
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#
# Get the package names of the available ROS middleware implemenations.
#
# The result can be overridden by setting either a CMake or environment
# variable named ``RMW_IMPLEMENTATIONS``.
# The variable can contain RMW implementation names separated by the platform
# specific path separator.
# Including an unavailable RMW implementation results in a fatal error message.
#
# :param var: the output variable name containing the package names
# :type var: list of strings
#
Expand All @@ -24,5 +30,32 @@ function(get_available_rmw_implementations var)
list(REMOVE_ITEM middleware_implementations "rmw_implementation")
list(SORT middleware_implementations)
endif()

# use explicitly provided list if provided
# option()
if(NOT "$ENV{RMW_IMPLEMENTATIONS}" STREQUAL "")
string(REPLACE ":" ";" RMW_IMPLEMENTATIONS "$ENV{RMW_IMPLEMENTATIONS}")
endif()
if(NOT "${RMW_IMPLEMENTATIONS}" STREQUAL "")
# check if given RMW implementations are available
foreach(rmw_implementation ${RMW_IMPLEMENTATIONS})
if(NOT "${rmw_implementation}" IN_LIST middleware_implementations)
message(FATAL_ERROR
"The RMW implementation '${rmw_implementation}' specified in "
"'RMW_IMPLEMENTATIONS' is not available ("
"${middleware_implementations})")
endif()
endforeach()
set(filtered)
foreach(rmw_implementation ${middleware_implementations})
if("${rmw_implementation}" IN_LIST RMW_IMPLEMENTATIONS)
list(APPEND filtered "${rmw_implementation}")
endif()
set(middleware_implementations ${filtered})
endforeach()
message(STATUS
"Filtered available RMW implementations: ${middleware_implementations}")
endif()

set(${var} ${middleware_implementations} PARENT_SCOPE)
endfunction()

0 comments on commit 71b000c

Please sign in to comment.