build(cmake): Modernize target-scoped CMake configuration#3377
Merged
Conversation
Raise the minimum CMake version range to 3.16...3.28 so CMake 4.x no longer treats the project as relying on removed pre-3.5 policy compatibility. The range preserves a conservative 3.16 runtime floor while documenting policy validation through 3.28.
Move shared compile definitions, include paths, options, and link dependencies onto interface targets so top-level, src, tools, tests, and standalone examples consume consistent build settings without relying on global directory state. Examples now share a small CMake helper, and the gtest download path is updated to configure with modern CMake while keeping downloaded gtest headers ahead of Homebrew's C++17-only installation.
chenBright
reviewed
Jul 9, 2026
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:
The CMake build files still rely on legacy global include directories, compile flags, and duplicated per-example configuration. This makes target behavior harder to
reason about and causes standalone examples/tests to drift from the main build configuration.
What is changed and the side effects?
Changed:
src,tools, andtestCMake targets with target-scoped configuration.brpc_common_configfor common compile definitions, include paths, options, and features.example/cmake/BrpcExample.cmake.3.16...3.28.Side effects:
Standalone examples now consistently require CMake 3.16 or newer, matching the main project requirement.
DOWNLOAD_GTEST=ONcreates a copied gtest include directory in the test build tree to avoid header conflicts with system-installed gtest.Performance effects:
No runtime performance impact expected. This is a build-system-only change.
Breaking backward compatibility:
No source/API compatibility break expected. Users building standalone examples with CMake older than 3.16 will need to upgrade CMake.
Check List:
Verification
Passed:
cmake -S . -B build -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3cmake --build build -j6cmake -S . -B build-tests -DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3 -DBUILD_UNIT_TESTS=ON -DDOWNLOAD_GTEST=ONcmake --build build-tests -j6echo_c++,http_c++, andmemcache_c++Known macOS arm64 test issues:
test_butilfails inStackTraceTest.find_symbolbthread_fd_unittestfails inFDTest.ping_pongrdma_performancestandalone example was not tested becauseibverbsis unavailable on macOS