Skip to content

build(example): extract shared CMake dependency helper for examples#3391

Open
darion-yaphet wants to merge 1 commit into
apache:masterfrom
darion-yaphet:migrate-example-mysql-cmake-helper
Open

build(example): extract shared CMake dependency helper for examples#3391
darion-yaphet wants to merge 1 commit into
apache:masterfrom
darion-yaphet:migrate-example-mysql-cmake-helper

Conversation

@darion-yaphet

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:

Example CMakeLists.txt files duplicate the same dependency discovery and link setup (brpc, protobuf, gflags, leveldb, openssl, thrift, Darwin flags). That makes
MySQL and other examples hard to maintain and easy to drift.

What is changed and the side effects?

Changed:

  • Add brpc_example_find_common_deps in example/cmake/BrpcExample.cmake to centralize common dependency lookup and DYNAMIC_LIB construction.
  • Migrate MySQL and other example CMakeLists.txt files to call the helper, removing duplicated find/link boilerplate.
  • Implement the helper as a CMake macro so variables such as CMAKE_PREFIX_PATH, include paths, and library lists propagate to the caller scope.
  • Keep example-specific deps local (e.g. MySQL readline/ncurses/thriftnb, redis/http gperftools).
    Side effects:
  • Performance effects: None expected (build-system only).
  • Breaking backward compatibility: Low risk. Example CMake entry points are simplified; users who build examples via each directory's CMakeLists.txt should use
    brpc_example_find_common_deps / existing BrpcExample.cmake helpers instead of the removed duplicated blocks. LINK_SO behavior is preserved.

Check List:

Example CMakeLists duplicated the same dependency discovery and link
setup. Move that into brpc_example_find_common_deps in
BrpcExample.cmake, migrate MySQL and other examples to use it, and
implement the helper as a macro so CMAKE_PREFIX_PATH, include paths,
and DYNAMIC_LIB propagate to the caller scope.
Example-specific deps stay local (e.g. readline/ncurses/thriftnb for
MySQL, gperftools for redis/http). LINK_SO behavior is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant