From d72f1cc2e4a9c126419b40418c99b75847565af9 Mon Sep 17 00:00:00 2001 From: wangchenguang Date: Sat, 29 Aug 2026 18:48:21 +0800 Subject: [PATCH] fix(cmake): prefer generated proto headers over in-source leftovers Make-generated src/**/*.pb.h can shadow newer build-dir headers and break compiles after proto updates such as EPROGREADTIMEOUT. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93113b6fc4..47c1458625 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,6 @@ set(BRPC_COMMON_COMPILE_OPTIONS) set(BRPC_COMMON_DEFINITIONS) set(BRPC_COMMON_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR} ) set(BRPC_COMMON_LINK_OPTIONS) set(BRPC_CXX_STANDARD 14) @@ -417,6 +416,10 @@ endif() list(REMOVE_DUPLICATES BRPC_COMMON_INCLUDE_DIRS) add_library(brpc_common_config INTERFACE) +# Generated protobuf headers live in the build directory. Search it before src/ +# so leftover in-source *.pb.h (gitignored, produced by Make) cannot shadow +# updated .proto files such as errno.proto. +target_include_directories(brpc_common_config BEFORE INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(brpc_common_config INTERFACE ${BRPC_COMMON_INCLUDE_DIRS}) target_compile_definitions(brpc_common_config INTERFACE ${BRPC_COMMON_DEFINITIONS}) target_compile_options(brpc_common_config INTERFACE ${BRPC_COMMON_COMPILE_OPTIONS})