16
16
#
17
17
# ================================= Apache 2.0 =================================
18
18
19
+ if (POLICY CMP0148)
20
+ cmake_policy (SET CMP0148 OLD)
21
+ endif ()
22
+
19
23
find_package (PythonInterp REQUIRED)
20
24
if (NOT PYTHON_EXECUTABLE)
21
25
message (FATAL_ERROR "Variable 'PYTHON_EXECUTABLE' must not be empty" )
@@ -53,26 +57,29 @@ rosidl_write_generator_arguments(
53
57
TARGET_DEPENDENCIES ${_target_dependencies}
54
58
ADDITIONAL_FILES "${_proto_include_dirs} " )
55
59
56
- execute_process (
57
- COMMAND "${PYTHON_EXECUTABLE} " "${rosidl_adapter_proto_BIN} "
58
- --generator-arguments-file "${generator_arguments_file} "
59
- --protoc-path "${Protobuf_PROTOC_EXECUTABLE} "
60
- ERROR_VARIABLE error
61
- RESULT_VARIABLE result
62
- )
63
-
64
- if (NOT result EQUAL 0)
65
- message (FATAL_ERROR "Proto file generation failed, error code: ${error} " )
66
- endif ()
67
-
68
60
set (rosidl_adapter_proto_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR} /rosidl_adapter_proto" )
69
61
foreach (_abs_idl_file ${rosidl_generate_interfaces_ABS_IDL_FILES} )
70
62
get_filename_component (_parent_folder "${_abs_idl_file} " DIRECTORY )
71
63
get_filename_component (_parent_folder "${_parent_folder} " NAME )
72
64
get_filename_component (_idl_name "${_abs_idl_file} " NAME_WE )
73
65
list (APPEND rosidl_adapter_proto_GENERATED_CPP "${rosidl_adapter_proto_OUTPUT_DIR} /${_parent_folder} /${_idl_name} .pb.cc" )
66
+ list (APPEND rosidl_adapter_proto_GENERATED_H "${rosidl_adapter_proto_OUTPUT_DIR} /${_parent_folder} /${_idl_name} .pb.h" )
67
+ list (APPEND rosidl_adapter_proto_GENERATED_PROTO "${rosidl_adapter_proto_OUTPUT_DIR} /${_parent_folder} /${_idl_name} .proto" )
74
68
endforeach ()
75
69
70
+ add_custom_command (
71
+ OUTPUT ${rosidl_adapter_proto_GENERATED_CPP}
72
+ ${rosidl_adapter_proto_GENERATED_H}
73
+ ${rosidl_adapter_proto_GENERATED_PROTO}
74
+ COMMAND "${PYTHON_EXECUTABLE} "
75
+ ARGS "${rosidl_adapter_proto_BIN} "
76
+ --generator-arguments-file "${generator_arguments_file} "
77
+ --protoc-path "${Protobuf_PROTOC_EXECUTABLE} "
78
+ DEPENDS ${_target_dependencies} "${PYTHON_EXECUTABLE} "
79
+ COMMENT "Generating type support for Protobuf"
80
+ VERBATIM
81
+ )
82
+
76
83
# generate header to switch between export and import for a specific package
77
84
set (rosidl_adapter_proto_VISIBILITY_CONTROL_HEADER
78
85
"${rosidl_adapter_proto_OUTPUT_DIR} /rosidl_adapter_proto__visibility_control.h" )
@@ -93,4 +100,4 @@ install(
93
100
DIRECTORY ${rosidl_adapter_proto_OUTPUT_DIR}
94
101
DESTINATION "share/${PROJECT_NAME} "
95
102
PATTERN "*.proto"
96
- )
103
+ )
0 commit comments