protocolbuffers/protobuf

Support maintaining source directory structure at generated location when using protobuf_generate

Open

#17,349 创建于 2024年7月5日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)C++ (16,128 fork)batch import
c++cmakehelp wanted

仓库指标

Star
 (71,223 star)
PR 合并指标
 (平均合并 2天 11小时) (30 天内合并 185 个 PR)

描述

What language does this apply to? C++ but I suspect is it the same for all.

Describe the problem you are trying to solve. I use protobuf_generate to generate the .pb.h and .pb.cc. They are generated but they appear all in the same directory location loosing the original directory structure. In other words, the output is a flat directory.

Now, this happens because I need to set multiple paths with IMPORT_DIRS so that the import statements in my .proto files succeed at finding the other source files. This works perfectly and is in line with the fact that the variable is indeed IMPORT_DIRS and not IMPORT_DIR. It is also in line with the fact that the name starts with IMPORT, implying that it relates to the IMPORT statement in the proto files.

However, it appears that protobuf_generate overloads the definition of IMPORT_DIRS with an alternate use by using it as a ROOT directory in order to maintain the directory structure.

Describe the solution you'd like Use a discrete SRC_ROOT to specify the source base location.

贡献者指南