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})