Cmake issues (#53)

* Clean up cmake infrastructure for tests
This commit is contained in:
Jackie Kay 2016-04-26 15:54:51 -07:00
parent 148962dbc4
commit 11753a3dd3
3 changed files with 36 additions and 43 deletions

View file

@ -119,16 +119,12 @@ function(test_target_function)
rcl_add_custom_executable(service_fixture${target_suffix}
SRCS rcl/service_fixture.cpp
ENV ${extra_test_env}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}${target_suffix} ${extra_test_libraries}
AMENT_DEPENDENCIES ${rmw_implementation} "example_interfaces"
)
rcl_add_custom_executable(client_fixture${target_suffix}
SRCS rcl/client_fixture.cpp
ENV ${extra_test_env}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}${target_suffix} ${extra_test_libraries}
AMENT_DEPENDENCIES ${rmw_implementation} "example_interfaces"
)
@ -137,6 +133,7 @@ function(test_target_function)
service_fixture
client_fixture
ENV ${extra_test_env}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
TIMEOUT 15
#WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)

View file

@ -28,7 +28,14 @@
#include "../scope_exit.hpp"
#include "rcl/error_handling.h"
class TestServiceFixture : public ::testing::Test
#ifdef RMW_IMPLEMENTATION
# define CLASSNAME_(NAME, SUFFIX) NAME ## __ ## SUFFIX
# define CLASSNAME(NAME, SUFFIX) CLASSNAME_(NAME, SUFFIX)
#else
# define CLASSNAME(NAME, SUFFIX) NAME
#endif
class CLASSNAME (TestServiceFixture, RMW_IMPLEMENTATION) : public ::testing::Test
{
public:
rcl_node_t * node_ptr;
@ -106,7 +113,7 @@ wait_for_service_to_be_ready(
/* Basic nominal test of a service.
*/
TEST_F(TestServiceFixture, test_service_nominal) {
TEST_F(CLASSNAME(TestServiceFixture, RMW_IMPLEMENTATION), test_service_nominal) {
stop_memory_checking();
rcl_ret_t ret;
const rosidl_service_type_support_t * ts = ROSIDL_GET_TYPE_SUPPORT(

View file

@ -21,51 +21,40 @@ macro(rcl_add_custom_executable target)
cmake_parse_arguments(_ARG
"TRACE"
""
"SRCS;ENV;APPEND_ENV;APPEND_LIBRARY_DIRS;INCLUDE_DIRS;LIBRARIES;AMENT_DEPENDENCIES"
"SRCS;INCLUDE_DIRS;LIBRARIES;AMENT_DEPENDENCIES"
${ARGN})
if(_ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
"rcl_add_custom_executable() called with unused arguments:"
"${_ARG_UNPARSED_ARGUMENTS}")
endif()
if(_ARG_ENV)
set(_ARG_ENV "ENV" ${_ARG_ENV})
endif()
if(_ARG_APPEND_ENV)
set(_ARG_APPEND_ENV "APPEND_ENV" ${_ARG_APPEND_ENV})
endif()
if(_ARG_APPEND_LIBRARY_DIRS)
set(_ARG_APPEND_LIBRARY_DIRS "APPEND_LIBRARY_DIRS" ${_ARG_APPEND_LIBRARY_DIRS})
endif()
add_executable(${target} ${_ARG_SRCS})
if(TARGET ${target})
if(_ARG_TRACE)
message(STATUS "rcl_add_custom_executable() Target '${target}':")
endif()
# Add extra include directories, if any.
if(_ARG_INCLUDE_DIRS)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() INCLUDE_DIRS: ${_ARG_INCLUDE_DIRS}")
endif()
target_include_directories(${target} PUBLIC ${_ARG_INCLUDE_DIRS})
endif()
# Add extra link libraries, if any.
if(_ARG_LIBRARIES)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() LIBRARIES: ${_ARG_LIBRARIES}")
endif()
target_link_libraries(${target} ${_ARG_LIBRARIES})
endif()
# Add extra ament dependencies, if any.
if(_ARG_AMENT_DEPENDENCIES)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() AMENT_DEPENDENCIES: ${_ARG_AMENT_DEPENDENCIES}")
endif()
ament_target_dependencies(${target} ${_ARG_AMENT_DEPENDENCIES})
endif()
target_compile_definitions(${target}
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
if(_ARG_TRACE)
message(STATUS "rcl_add_custom_executable() Target '${target}':")
endif()
# Add extra include directories, if any.
if(_ARG_INCLUDE_DIRS)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() INCLUDE_DIRS: ${_ARG_INCLUDE_DIRS}")
endif()
target_include_directories(${target} PUBLIC ${_ARG_INCLUDE_DIRS})
endif()
# Add extra link libraries, if any.
if(_ARG_LIBRARIES)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() LIBRARIES: ${_ARG_LIBRARIES}")
endif()
target_link_libraries(${target} ${_ARG_LIBRARIES})
endif()
# Add extra ament dependencies, if any.
if(_ARG_AMENT_DEPENDENCIES)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() AMENT_DEPENDENCIES: ${_ARG_AMENT_DEPENDENCIES}")
endif()
ament_target_dependencies(${target} ${_ARG_AMENT_DEPENDENCIES})
endif()
target_compile_definitions(${target}
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
endmacro()