refactoring since type support changes

This commit is contained in:
William Woodall 2015-12-12 16:29:34 -08:00
parent 02f926c2c7
commit 34ae477e28
3 changed files with 117 additions and 90 deletions

View file

@ -5,11 +5,10 @@ project(rcl)
find_package(ament_cmake REQUIRED)
find_package(rcl_interfaces REQUIRED)
find_package(rmw REQUIRED)
find_package(rmw_implementation REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)
find_package(rosidl_generator_c REQUIRED)
ament_export_dependencies(rmw rosidl_generator_c)
ament_export_include_directories(include)
include_directories(include)
if(NOT WIN32)
@ -28,93 +27,44 @@ set(${PROJECT_NAME}_sources
src/rcl/time.c
src/rcl/timer.c
)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_sources})
ament_target_dependencies(${PROJECT_NAME}
"rcl_interfaces"
"rmw"
"rosidl_generator_c"
)
if(NOT WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-std=c11")
endif()
macro(target)
add_library(${PROJECT_NAME}${target_suffix} SHARED ${${PROJECT_NAME}_sources})
ament_target_dependencies(${PROJECT_NAME}${target_suffix}
"rcl_interfaces"
"rmw"
"rosidl_generator_c"
"${rmw_implementation}"
)
if(NOT WIN32)
set_target_properties(${PROJECT_NAME}${target_suffix} PROPERTIES COMPILE_FLAGS "-std=c11")
endif()
install(
TARGETS ${PROJECT_NAME}${target_suffix}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
endmacro()
call_for_each_rmw_implementation(target GENERATE_DEFAULT)
ament_export_dependencies(rcl_interfaces)
ament_export_dependencies(rmw)
ament_export_dependencies(rmw_implementation)
ament_export_dependencies(rosidl_generator_c)
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
if(AMENT_ENABLE_TESTING)
find_package(ament_cmake_gtest REQUIRED)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
set(extra_test_libraries)
set(extra_memory_tools_env PHONY=) # Use a phony env var so there is always at least one.
ament_find_gtest() # For GTEST_LIBRARIES
if(APPLE)
add_library(${PROJECT_NAME}_memory_tools_interpose SHARED test/memory_tools_osx_interpose.cpp)
target_link_libraries(${PROJECT_NAME}_memory_tools_interpose ${GTEST_LIBRARIES})
set_target_properties(${PROJECT_NAME}_memory_tools_interpose
PROPERTIES COMPILE_FLAGS "-std=c++11")
list(APPEND extra_test_libraries ${PROJECT_NAME}_memory_tools_interpose)
list(APPEND extra_memory_tools_env
DYLD_INSERT_LIBRARIES=$<TARGET_FILE:${PROJECT_NAME}_memory_tools_interpose>)
endif()
add_library(${PROJECT_NAME}_memory_tools SHARED test/memory_tools.cpp)
if(NOT WIN32)
set_target_properties(${PROJECT_NAME}_memory_tools PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(${PROJECT_NAME}_memory_tools ${GTEST_LIBRARIES} ${extra_test_libraries})
list(APPEND extra_test_libraries ${PROJECT_NAME}_memory_tools)
ament_add_gtest(test_memory_tools test/test_memory_tools.cpp ENV ${extra_memory_tools_env})
if(TARGET test_memory_tools)
target_include_directories(test_memory_tools PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_memory_tools PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_memory_tools ${PROJECT_NAME} ${extra_test_libraries})
endif()
ament_add_gtest(test_allocator test/rcl/test_allocator.cpp ENV ${extra_memory_tools_env})
if(TARGET test_allocator)
target_include_directories(test_allocator PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_allocator PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_allocator ${PROJECT_NAME} ${extra_test_libraries})
endif()
ament_add_gtest(test_time test/rcl/test_time.cpp ENV ${extra_memory_tools_env})
if(TARGET test_time)
target_include_directories(test_time PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_time PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_time ${PROJECT_NAME} ${extra_test_libraries})
endif()
ament_add_gtest(test_common
test/rcl/test_common.cpp
ENV
${extra_memory_tools_env}
EMPTY_TEST=
NORMAL_TEST=foo
)
if(TARGET test_common)
target_include_directories(test_common PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_common PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_common ${PROJECT_NAME} ${extra_test_libraries})
endif()
add_subdirectory(test)
endif()
ament_package()

View file

@ -10,17 +10,20 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rmw</build_depend>
<!-- This ensures the rmw impls are built first. -->
<build_depend>rmw_implementation</build_depend>
<build_export_depend>rmw</build_export_depend>
<depend>rcl_interfaces</depend>
<depend>rosidl_generator_c</depend>
<build_depend>rcl_interfaces</build_depend>
<build_depend>rmw_implementation_cmake</build_depend>
<build_depend>rosidl_generator_c</build_depend>
<build_export_depend>rcl_interfaces</build_export_depend>
<build_export_depend>rosidl_generator_c</build_export_depend>
<depend>rmw_implementation</depend>
<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>rmw</test_depend>
<export>
<build_type>ament_cmake</build_type>

74
rcl/test/CMakeLists.txt Normal file
View file

@ -0,0 +1,74 @@
if(AMENT_ENABLE_TESTING)
set(extra_test_libraries)
set(extra_memory_tools_env PHONY=) # Use a phony env var so there is always at least one.
ament_find_gtest() # For GTEST_LIBRARIES
if(APPLE)
add_library(${PROJECT_NAME}_memory_tools_interpose SHARED memory_tools_osx_interpose.cpp)
target_link_libraries(${PROJECT_NAME}_memory_tools_interpose ${GTEST_LIBRARIES})
set_target_properties(${PROJECT_NAME}_memory_tools_interpose
PROPERTIES COMPILE_FLAGS "-std=c++11")
list(APPEND extra_test_libraries ${PROJECT_NAME}_memory_tools_interpose)
list(APPEND extra_memory_tools_env
DYLD_INSERT_LIBRARIES=$<TARGET_FILE:${PROJECT_NAME}_memory_tools_interpose>)
endif()
add_library(${PROJECT_NAME}_memory_tools SHARED memory_tools.cpp)
if(NOT WIN32)
set_target_properties(${PROJECT_NAME}_memory_tools PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(${PROJECT_NAME}_memory_tools ${GTEST_LIBRARIES} ${extra_test_libraries})
list(APPEND extra_test_libraries ${PROJECT_NAME}_memory_tools)
ament_add_gtest(test_memory_tools test_memory_tools.cpp ENV ${extra_memory_tools_env})
if(TARGET test_memory_tools)
target_include_directories(test_memory_tools PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_memory_tools PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_memory_tools ${PROJECT_NAME} ${extra_test_libraries})
endif()
ament_add_gtest(test_allocator rcl/test_allocator.cpp ENV ${extra_memory_tools_env})
if(TARGET test_allocator)
target_include_directories(test_allocator PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_allocator PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_allocator ${PROJECT_NAME} ${extra_test_libraries})
endif()
ament_add_gtest(test_time rcl/test_time.cpp ENV ${extra_memory_tools_env})
if(TARGET test_time)
target_include_directories(test_time PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_time PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_time ${PROJECT_NAME} ${extra_test_libraries})
endif()
ament_add_gtest(test_common
rcl/test_common.cpp
ENV
${extra_memory_tools_env}
EMPTY_TEST=
NORMAL_TEST=foo
)
if(TARGET test_common)
target_include_directories(test_common PUBLIC
${rcl_interfaces_INCLUDE_DIRS}
${rmw_INCLUDE_DIRS}
)
if(NOT WIN32)
set_target_properties(test_common PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
target_link_libraries(test_common ${PROJECT_NAME} ${extra_test_libraries})
endif()
endif()