From 7534ac360a759c46e70ff00988b4191282500369 Mon Sep 17 00:00:00 2001 From: zhangyi1357 <34409786+zhangyi1357@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:48:48 +0800 Subject: [PATCH] build: add external proto path for source directory (#99) Configure the build system to include the source directory in the proto path for all relevant targets, ensuring improved resolution of proto files during code generation. --- cmake/ProtobufGenCode.cmake | 2 ++ .../ProtobufAimRTRpcGenCode.cmake | 1 + .../ProtobufAimRTRpcGenCode.cmake | 1 + 3 files changed, 4 insertions(+) diff --git a/cmake/ProtobufGenCode.cmake b/cmake/ProtobufGenCode.cmake index 96dcdb541..e79c660d0 100644 --- a/cmake/ProtobufGenCode.cmake +++ b/cmake/ProtobufGenCode.cmake @@ -21,6 +21,7 @@ function(add_protobuf_gencode_target_for_proto_path) get_target_property(DEP_PROTO_TARGET_PROTO_PATH ${CUR_DEP_PROTO_TARGET} PROTO_PATH) list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${DEP_PROTO_TARGET_PROTO_PATH}") endforeach() + list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${protobuf_SOURCE_DIR}/src") list(REMOVE_DUPLICATES PROTOC_EXTERNAL_PROTO_PATH_ARGS) get_property(PROTOC_NAMESPACE GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY) @@ -84,6 +85,7 @@ function(add_protobuf_gencode_target_for_one_proto_file) get_target_property(DEP_PROTO_TARGET_PROTO_PATH ${CUR_DEP_PROTO_TARGET} PROTO_PATH) list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${DEP_PROTO_TARGET_PROTO_PATH}") endforeach() + list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${protobuf_SOURCE_DIR}/src") list(REMOVE_DUPLICATES PROTOC_EXTERNAL_PROTO_PATH_ARGS) get_property(PROTOC_NAMESPACE GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY) diff --git a/src/tools/protoc_plugin_cpp_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake b/src/tools/protoc_plugin_cpp_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake index 244b52e6d..39bde92cb 100644 --- a/src/tools/protoc_plugin_cpp_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake +++ b/src/tools/protoc_plugin_cpp_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake @@ -21,6 +21,7 @@ function(add_protobuf_aimrt_rpc_gencode_target_for_proto_files) get_target_property(DEP_PROTO_TARGET_PROTO_PATH ${CUR_DEP_PROTO_TARGET} PROTO_PATH) list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${DEP_PROTO_TARGET_PROTO_PATH}") endforeach() + list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${protobuf_SOURCE_DIR}/src") list(REMOVE_DUPLICATES PROTOC_EXTERNAL_PROTO_PATH_ARGS) get_property(PROTOC_NAMESPACE GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY) diff --git a/src/tools/protoc_plugin_py_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake b/src/tools/protoc_plugin_py_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake index 301902d6b..8cd3f01c3 100644 --- a/src/tools/protoc_plugin_py_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake +++ b/src/tools/protoc_plugin_py_gen_aimrt_cpp_rpc/ProtobufAimRTRpcGenCode.cmake @@ -21,6 +21,7 @@ function(add_protobuf_aimrt_rpc_gencode_target_for_proto_files) get_target_property(DEP_PROTO_TARGET_PROTO_PATH ${CUR_DEP_PROTO_TARGET} PROTO_PATH) list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${DEP_PROTO_TARGET_PROTO_PATH}") endforeach() + list(APPEND PROTOC_EXTERNAL_PROTO_PATH_ARGS "--proto_path=${protobuf_SOURCE_DIR}/src") list(REMOVE_DUPLICATES PROTOC_EXTERNAL_PROTO_PATH_ARGS) get_property(PROTOC_NAMESPACE GLOBAL PROPERTY PROTOC_NAMESPACE_PROPERTY)