diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 6405c3496..968884007 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -1,5 +1,6 @@ set(ENV{proto_message} "proto_message") +set(ENV{struct_pb_options} "namespace=zhito.inner_struct,converter_namespace=zhito.converter") # 设置编译器选项 add_compile_options(-Wno-attributes) @@ -30,27 +31,21 @@ protobuf_generate_python(PROTO_PYTHON_SRCS protobuf_generate_struct_pb(PROTO_STRUCT_SRCS PROTO_STRUCT_HDRS ${PROTO_FILES} -OPTION "namespace=zhito.inner_struct,converter_namespace=zhito.converter" +OPTION $ENV{struct_pb_options} ) add_library(proto_common OBJECT - ${PROTO_SRCS} - ${PROTO_HDRS} + ${PROTO_SRCS} ${PROTO_STRUCT_SRCS} - ${PROTO_STRUCT_HDRS} ${PROTO_PYTHON_SRCS} ) target_link_libraries(proto_common protobuf::libprotobuf ) target_include_directories(proto_common PUBLIC - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_LIST_DIR} - ${PCL_INCLUDE_DIRS} - ${OpenCV_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR}/src/protoc-plugin + ${CMAKE_CURRENT_LIST_DIR} # base.h + ${CMAKE_BINARY_DIR}/src/protoc-plugin # proto_to_struct.h ) diff --git a/src/example/message/CMakeLists.txt b/src/example/message/CMakeLists.txt index e201c4c50..757361897 100644 --- a/src/example/message/CMakeLists.txt +++ b/src/example/message/CMakeLists.txt @@ -2,29 +2,23 @@ file(GLOB PROTO_FILES "*.proto") # generate .pb.cc .pb.h -protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS - ${PROTO_FILES} -) +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES}) -protobuf_generate_python(PROTO_PYTHON_SRCS - ${PROTO_FILES} -) +protobuf_generate_python(PROTO_PYTHON_SRCS ${PROTO_FILES}) # 删除点云,图片proto记录文件 list(FILTER PROTO_FILES EXCLUDE REGEX "pointcloud\\.proto$|image\\.proto$") protobuf_generate_struct_pb(PROTO_STRUCT_SRCS PROTO_STRUCT_HDRS ${PROTO_FILES} -OPTION "namespace=zhito.inner_struct,converter_namespace=zhito.converter" +OPTION $ENV{struct_pb_options} ) add_library($ENV{proto_message} OBJECT - # zpointcloud.cpp zimage.cpp - ${PROTO_SRCS} - ${PROTO_HDRS} + # + ${PROTO_SRCS} ${PROTO_STRUCT_SRCS} - ${PROTO_STRUCT_HDRS} ${PROTO_PYTHON_SRCS} ) @@ -34,14 +28,13 @@ target_link_libraries($ENV{proto_message} protobuf::libprotobuf ) target_include_directories($ENV{proto_message} PUBLIC - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/.. # 找到common - ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} # 找到build目录下的zframe.struct_pb.h ${CMAKE_CURRENT_LIST_DIR}/.. # 找到iguana + ${CMAKE_CURRENT_BINARY_DIR}/.. # 找到common +# 第三方库 ${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR}/src/protoc-plugin ) diff --git a/src/example/message/pointcloud.proto b/src/example/message/pointcloud.proto index 1273596e6..7e319d7a9 100644 --- a/src/example/message/pointcloud.proto +++ b/src/example/message/pointcloud.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package zhito.inner_class; import "zframe.proto"; -import "base.proto"; -import "proto_to_struct.proto"; +// import "base.proto"; +// import "proto_to_struct.proto"; message ZPointCloudXYZIT { ZFrame header = 1 ; diff --git a/src/example/message/zframe.proto b/src/example/message/zframe.proto index 1bee861d9..88368d9b0 100644 --- a/src/example/message/zframe.proto +++ b/src/example/message/zframe.proto @@ -1,8 +1,8 @@ syntax = "proto3"; package zhito.inner_class; -import "base.proto"; -import "proto_to_struct.proto"; +// import "base.proto"; +// import "proto_to_struct.proto"; enum ZFrameType{ None = 0; VEHICLE_MODEL = 1; // 车辆运动约束虚拟帧 diff --git a/src/example/message/zimage.cpp b/src/example/message/zimage.cpp index 5738d06da..3e07915bf 100644 --- a/src/example/message/zimage.cpp +++ b/src/example/message/zimage.cpp @@ -1,4 +1,4 @@ -#include "zimage.hpp" +#include "src/example/message/zimage.hpp" #include #include diff --git a/src/example/message/zimage.hpp b/src/example/message/zimage.hpp index e744b017d..4954d252e 100644 --- a/src/example/message/zimage.hpp +++ b/src/example/message/zimage.hpp @@ -2,8 +2,8 @@ #include -#include "zframe.struct_pb.h" -#include "image.pb.h" +#include "src/example/message/zframe.struct_pb.h" +#include "src/example/message/image.pb.h" #include diff --git a/src/example/message/zpointcloud.cpp b/src/example/message/zpointcloud.cpp index 7abf65a26..96b9fadd1 100644 --- a/src/example/message/zpointcloud.cpp +++ b/src/example/message/zpointcloud.cpp @@ -1,4 +1,4 @@ -#include "zpointcloud.hpp" +#include "src/example/message/zpointcloud.hpp" #include #include diff --git a/src/example/message/zpointcloud.hpp b/src/example/message/zpointcloud.hpp index f2bc4fb82..3ad46b438 100644 --- a/src/example/message/zpointcloud.hpp +++ b/src/example/message/zpointcloud.hpp @@ -2,9 +2,9 @@ #include -#include "zframe.struct_pb.h" -#include "pointcloud.pb.h" -#include "xyzit_points.hpp" +#include "src/example/message/zframe.struct_pb.h" +#include "src/example/message/pointcloud.pb.h" +#include "src/example/message/xyzit_points.hpp" // save to file #include