Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow forwarding of working directory and launch file args to add_rostest from gtest wrapper functions #2294

Open
wants to merge 3 commits into
base: noetic-devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions tools/rostest/cmake/rostest-extras.cmake.em
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down