Unverified Commit 956bfabf authored by Guilhem Saurel's avatar Guilhem Saurel Committed by GitHub
Browse files

Merge pull request #13 from nim65s/devel

[CMake] assume ROS 1 by default
parents 33ae8c78 0d117c6c
Pipeline #16968 passed with stage
in 24 seconds
include: http://rainboard.laas.fr/project/dynamic-graph-bridge-msgs/.gitlab-ci.yml include: http://rainboard.laas.fr/project/dynamic_graph_bridge_msgs/.gitlab-ci.yml
...@@ -5,80 +5,77 @@ set(PROJECT_NAME dynamic_graph_bridge_msgs) ...@@ -5,80 +5,77 @@ set(PROJECT_NAME dynamic_graph_bridge_msgs)
set(PROJECT_DESCRIPTION "Dynamic graph bridge msgs ") set(PROJECT_DESCRIPTION "Dynamic graph bridge msgs ")
set(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}") set(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
if(DEFINED ENV{ROS_VERSION} ) if(DEFINED ENV{ROS_VERSION})
set(ROS_VERSION $ENV{ROS_VERSION})
else()
set(ROS_VERSION 1)
endif()
if ($ENV{ROS_VERSION} EQUAL 1) # if ROS1 if(ROS_VERSION EQUAL 1) # if ROS1
# Here we use the jrl-cmakemodules to package things properly. # Here we use the jrl-cmakemodules to package things properly.
set(CUSTOM_HEADER_DIR dynamic_graph_bridge_msgs) set(CUSTOM_HEADER_DIR dynamic_graph_bridge_msgs)
if(DEFINED ENV{ROS_VERSION} ) set(PROJECT_USE_CMAKE_EXPORT TRUE)
# ROS-1 include(cmake/base.cmake)
if ($ENV{ROS_VERSION} EQUAL 1)
set(PROJECT_USE_CMAKE_EXPORT TRUE)
endif()
endif()
include(cmake/base.cmake)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX C) COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX C)
project(${PROJECT_NAME} ${PROJECT_ARGS}) project(${PROJECT_NAME} ${PROJECT_ARGS})
# Declare build dependencies # Declare build dependencies
find_package(catkin REQUIRED COMPONENTS message_generation std_msgs) find_package(catkin REQUIRED COMPONENTS message_generation std_msgs)
# Add message files # Add message files
add_message_files(DIRECTORY msg FILES Matrix.msg Vector.msg) add_message_files(DIRECTORY msg FILES Matrix.msg Vector.msg)
# Add service files # Add service files
add_service_files( add_service_files(
DIRECTORY srv DIRECTORY srv
FILES RunCommand.srv RunPythonCommand.srv RunPythonFile.srv FILES RunCommand.srv RunPythonCommand.srv RunPythonFile.srv
) )
# And now generate the messages # And now generate the messages
generate_messages(DEPENDENCIES ${MESSAGE_DEPENDENCIES}) generate_messages(DEPENDENCIES ${MESSAGE_DEPENDENCIES})
add_library(${PROJECT_NAME} INTERFACE) add_library(${PROJECT_NAME} INTERFACE)
install(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib) install(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
install(FILES package.xml DESTINATION share/${PROJECT_NAME})
else() # if ROS2 else() # if ROS2
# Here ament is doing things ok. # Here ament is doing things ok.
project(${PROJECT_NAME}) project(${PROJECT_NAME})
find_package(ament_cmake REQUIRED) find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED) find_package(ament_cmake_python REQUIRED)
find_package(rosidl_default_generators REQUIRED) find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME} rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Matrix.msg" "msg/Matrix.msg"
"msg/Vector.msg" "msg/Vector.msg"
"srv/RunCommand.srv" "srv/RunCommand.srv"
"srv/RunPythonCommand.srv" "srv/RunPythonCommand.srv"
"srv/RunPythonFile.srv" "srv/RunPythonFile.srv"
) )
install(FILES package.xml DESTINATION share/${PROJECT_NAME}) ament_export_dependencies(rosidl_default_runtime)
ament_export_dependencies(rosidl_default_runtime) ament_package()
ament_package() endif()
endif()
if(BUILD_TESTING) install(FILES package.xml DESTINATION share/${PROJECT_NAME})
if ($ENV{ROS_VERSION} EQUAL 1) # if ROS-1
find_package(rostest REQUIRED)
add_rostest(tests/ros1/unit_test_ros.test)
else() # if ROS-2
include(CTest)
include(cmake/python.cmake)
findpython()
add_test(
NAME test_${PROJECT_NAME}_python
COMMAND ${PYTHON_EXECUTABLE} -m pytest -v
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/ros2)
set_tests_properties(
test_${PROJECT_NAME}_python
PROPERTIES
ENVIRONMENT
"PYTHONPATH=${CMAKE_BINARY_DIR}/rosidl_generator_py/:${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH}"
)
endif()
endif() # BUILD_TESTING
endif() if(BUILD_TESTING)
if(ROS_VERSION EQUAL 1) # if ROS1
find_package(rostest REQUIRED)
add_rostest(tests/ros1/unit_test_ros.test)
else() # if ROS-2
include(CTest)
include(cmake/python.cmake)
findpython()
add_test(
NAME test_${PROJECT_NAME}_python
COMMAND ${PYTHON_EXECUTABLE} -m pytest -v
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/ros2)
set_tests_properties(
test_${PROJECT_NAME}_python
PROPERTIES
ENVIRONMENT
"PYTHONPATH=${CMAKE_BINARY_DIR}/rosidl_generator_py/:${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH}"
)
endif()
endif() # BUILD_TESTING
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment