Skip to content

Commit

Permalink
均使用protobuf_generate_modified
Browse files Browse the repository at this point in the history
  • Loading branch information
171930433 committed Mar 24, 2024
1 parent d0c8ffa commit 39c650f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ project(yaLanTingLibs

# set(SYSROOT_DIR /opt/zhito/sysroot)
# set(CMAKE_PREFIX_PATH "/home/gsk/pro/CyberRT/install")
if(NOT ${CMAKE_PREFIX_PATH})
if(NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH "/home/gsk/pro/ubuntu2204_docker/install")
endif()

Expand All @@ -25,5 +25,5 @@ add_subdirectory(src/protoc-plugin)
option(BUILD_EXAMPLES OFF)

if(BUILD_EXAMPLES)
add_subdirectory(src/example)
add_subdirectory(src/example)
endif()
4 changes: 2 additions & 2 deletions src/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ file(GLOB_RECURSE PROTO_FILES "*.proto")
# "/home/gsk/pro/yalantinglibs/src/example/message/imu.proto" )


protobuf_generate(
protobuf_generate_modified(
LANGUAGE cpp
OUT_VAR PROTO_CLASS_SRCS
IMPORT_DIRS ${CMAKE_SOURCE_DIR}
Expand All @@ -31,7 +31,7 @@ protobuf_generate(
)


protobuf_generate(
protobuf_generate_modified(
LANGUAGE python
OUT_VAR PROTO_PYTHON_SRCS
IMPORT_DIRS ${CMAKE_SOURCE_DIR}
Expand Down
16 changes: 13 additions & 3 deletions src/protoc-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin)

find_package(Protobuf REQUIRED)
file(GLOB SRCS "*.cpp" "*.cc" "*.h")
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS proto_to_struct.proto)
# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS proto_to_struct.proto)

add_executable(protoc-gen-struct_pb ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS})
target_include_directories(protoc-gen-struct_pb PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
include(cmake/struct_pb.cmake)
protobuf_generate_modified(
LANGUAGE cpp
OUT_VAR PROTO_CLASS_SRCS
IMPORT_DIRS ${CMAKE_SOURCE_DIR}
PROTOS proto_to_struct.proto
PROTOC_OUT_DIR ${CMAKE_BINARY_DIR}
)


add_executable(protoc-gen-struct_pb ${SRCS} ${PROTO_CLASS_SRCS})
target_include_directories(protoc-gen-struct_pb PUBLIC ${CMAKE_BINARY_DIR})
target_link_libraries(protoc-gen-struct_pb PUBLIC protobuf::libprotoc protobuf::libprotobuf)
install(
TARGETS protoc-gen-struct_pb
Expand Down
2 changes: 1 addition & 1 deletion src/protoc-plugin/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "google/protobuf/descriptor.h"

// added
#include "proto_to_struct.pb.h"
#include "src/protoc-plugin/proto_to_struct.pb.h"

struct Options {
Options(const google::protobuf::FileDescriptor* f) : f(f) {}
Expand Down

0 comments on commit 39c650f

Please sign in to comment.