1+ # Copyright 2016-2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+
16+ # list msg files
17+ set (_ros_idl_files "" )
18+ foreach (_idl_file ${rosidl_generate_interfaces_IDL_FILES} )
19+ get_filename_component (_extension "${_idl_file} " EXT )
20+ # Skip .srv files
21+ if (_extension STREQUAL ".msg" )
22+ list (APPEND _ros_idl_files "${_idl_file} " )
23+ endif ()
24+ endforeach ()
25+
26+
27+ # Set output dir
28+ set (_output_path "${CMAKE_CURRENT_BINARY_DIR } /../micro_ros_agent/xml_gen" )
29+
30+
31+ # check if all templates exits
32+ set (target_dependencies
33+ "${micro_ros_agent_BIN} "
34+ "${micro_ros_agent_GENERATOR_FILES} "
35+ ${rosidl_generate_interfaces_IDL_FILES}
36+ ${_dependency_files} )
37+ foreach (dep ${target_dependencies} )
38+ if (NOT EXISTS "${dep} " )
39+ message (FATAL_ERROR "Target dependency '${dep} ' does not exist" )
40+ endif ()
41+ endforeach ()
42+
43+
44+ # generate script argument file
45+ set (generator_arguments_file "${CMAKE_CURRENT_BINARY_DIR } /micro_ros_agent__arguments.json" )
46+ rosidl_write_generator_arguments (
47+ "${generator_arguments_file} "
48+ PACKAGE_NAME "${PROJECT_NAME } "
49+ ROS_INTERFACE_FILES "${rosidl_generate_interfaces_IDL_FILES} "
50+ ROS_INTERFACE_DEPENDENCIES "${_dependencies} "
51+ OUTPUT_DIR "${_output_path} "
52+ TEMPLATE_DIR "${micro_ros_agent_DEFAULT_PROFILES_DIR} "
53+ TARGET_DEPENDENCIES ${target_dependencies}
54+ ADDITIONAL_FILES ${_dds_idl_files}
55+ )
56+
57+
58+ # Execute python script
59+ execute_process (
60+ COMMAND ${PYTHON_EXECUTABLE} ${micro_ros_agent_BIN}
61+ --generator-arguments-file "${generator_arguments_file} "
62+ )
63+
64+
65+ #Install
66+ install (
67+ DIRECTORY "${_output_path} /"
68+ DESTINATION "../micrortps_agent/bin"
69+ )
0 commit comments