fix(cmake): prefer generated proto headers over in-source leftovers - #3506
Open
darion-yaphet wants to merge 1 commit into
Open
fix(cmake): prefer generated proto headers over in-source leftovers#3506darion-yaphet wants to merge 1 commit into
darion-yaphet wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a CMake include-path precedence issue in bRPC’s build system so that build-directory generated protobuf headers are preferred over stale, Make-generated (gitignored) src/**/*.pb.h leftovers. This prevents compilation against outdated proto headers after .proto changes.
Changes:
- Reorders
BRPC_COMMON_INCLUDE_DIRSto put${CMAKE_CURRENT_BINARY_DIR}before${PROJECT_SOURCE_DIR}/src. - Prepends the build directory to
brpc_common_configinclude dirs usingtarget_include_directories(... BEFORE ...)to ensure build-generated headers win in include resolution.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
70
to
73
| set(BRPC_COMMON_INCLUDE_DIRS | ||
| ${PROJECT_SOURCE_DIR}/src | ||
| ${CMAKE_CURRENT_BINARY_DIR} | ||
| ${PROJECT_SOURCE_DIR}/src | ||
| ) |
Make-generated src/**/*.pb.h can shadow newer build-dir headers and break compiles after proto updates such as EPROGREADTIMEOUT.
darion-yaphet
force-pushed
the
fix/generated-proto-include-order
branch
from
August 31, 2026 06:02
6ccd87d to
d72f1cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
CMake searched
${PROJECT_SOURCE_DIR}/srcbefore the build directory. Make generates protobuf headers in-tree (src/**/*.pb.h, gitignored). After a.protoupdate, CMake already writes the new header into the build directory, but the compiler still picks the leftover in-source file.This showed up after #3469 (
EPROGREADTIMEOUT):src/brpc/errno.protoandbuild/brpc/errno.pb.hboth hadEPROGREADTIMEOUT = 1019; the stalesrc/brpc/errno.pb.hstill stopped atEREJECT = 1018.What is changed and the side effects?
Changed:
${CMAKE_CURRENT_BINARY_DIR}as aBEFOREinclude onbrpc_common_config, so generated protobuf headers are searched beforesrc/and leftover Make-generated*.pb.hcannot shadow them.Side effects:
Performance effects: none. Compile-time include order only; no runtime change.
Breaking backward compatibility: no. Generated headers remain the source of truth. In-source
*.pb.hfrom Make is still valid when it is up to date; it just no longer wins over a newer build-dir copy. Existing Make and Bazel flows are unchanged.Check List: