diff --git a/tools/rostest/cmake/rostest-extras.cmake.em b/tools/rostest/cmake/rostest-extras.cmake.em index 69b06fdf76..490d0ec62d 100644 --- a/tools/rostest/cmake/rostest-extras.cmake.em +++ b/tools/rostest/cmake/rostest-extras.cmake.em @@ -76,13 +76,27 @@ function(_add_rostest_google_test type target launch_file) message(FATAL_ERROR "add_rostest_${type}() needs at least one file argument to compile a ${type_upper} executable") endif() if(${type_upper}_FOUND) + set(single_value_args "WORKING_DIRECTORY") + set(multi_value_args "ARGS") + + cmake_parse_arguments(_arg "" "${single_value_args}" "${multi_value_args}" ${ARGN}) + + set(extra_args "") + set(sources "${ARGN}") + foreach(arg IN ITEMS ${single_value_args} ${multi_value_args}) + if(DEFINED _arg_${arg}) + string(REPLACE "${arg};${_arg_${arg}}" "" sources "${sources}") + string(APPEND extra_args "${arg};${_arg_${arg}};") + endif(DEFINED _arg_${arg}) + endforeach() + include_directories(${${type_upper}_INCLUDE_DIRS}) - add_executable(${target} EXCLUDE_FROM_ALL ${ARGN}) + add_executable(${target} EXCLUDE_FROM_ALL ${sources}) target_link_libraries(${target} ${${type_upper}_LIBRARIES}) if(TARGET tests) add_dependencies(tests ${target}) endif() - add_rostest(${launch_file} DEPENDENCIES ${target}) + add_rostest(${launch_file} DEPENDENCIES ${target} ${extra_args}) endif() endfunction()