This is an automated email from the ASF dual-hosted git repository.
nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new e4836b755 [CELEBORN-2266] Modernize Protobuf CMake usage and add
install rules
e4836b755 is described below
commit e4836b75527ace35837ee0c87b6585b1d8701b66
Author: jay.narale <[email protected]>
AuthorDate: Thu Feb 19 16:23:11 2026 +0800
[CELEBORN-2266] Modernize Protobuf CMake usage and add install rules
### What changes were proposed in this pull request?
- Switched Protobuf CMake integration from the legacy FindProtobuf module
to modern CONFIG mode with imported targets (protobuf::protoc,
protobuf::libprotobuf).
- Added install() rules for public headers, generated proto headers, and
static libraries so the C++ client can be consumed as an installed package.
- Added missing #include <set> in CelebornUtils.h.
### Why are the changes needed?
The legacy FindProtobuf module-variable style (${PROTOBUF_LIBRARY}, bare
protoc command) is fragile and does not work reliably with package managers
like vcpkg or Conan that provide Protobuf via CMake config files. Switching to
CONFIG mode and imported targets is the modern CMake best practice and ensures
the correct protoc binary and library are used regardless of the build
environment.
The install rules are needed so that downstream projects can consume the
Celeborn C++ client from a clean install prefix rather than pointing directly
at the source and build trees.
The missing <set> include was causing compilation failures in certain
toolchain configurations where the header was not transitively included.
### Does this PR resolve a correctness bug?
No.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
CI.
Closes #3602 from jaystarshot/u-c.
Authored-by: jay.narale <[email protected]>
Signed-off-by: SteNicholas <[email protected]>
---
cpp/CMakeLists.txt | 26 +++++++++++++++++++++++++-
cpp/celeborn/proto/CMakeLists.txt | 2 +-
cpp/celeborn/utils/CelebornUtils.h | 1 +
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index f24a8abff..8d54b62e3 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -156,7 +156,7 @@ set(ProtoGenSource
"${CMAKE_BINARY_DIR}/celeborn/proto/TransportMessagesCpp.pb.c
add_custom_command(
OUTPUT ${ProtoGenSource} ${ProtoGenHeader}
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/celeborn/proto
- COMMAND protoc --proto_path=${CMAKE_CURRENT_SOURCE_DIR}/celeborn/proto
--cpp_out=${CMAKE_BINARY_DIR}/celeborn/proto ${ProtoFile}
+ COMMAND protobuf::protoc
--proto_path=${CMAKE_CURRENT_SOURCE_DIR}/celeborn/proto
--cpp_out=${CMAKE_BINARY_DIR}/celeborn/proto ${ProtoFile}
DEPENDS ${ProtoFile}
VERBATIM)
add_custom_target(
@@ -175,3 +175,27 @@ if(CELEBORN_BUILD_TESTS)
endif()
add_subdirectory(celeborn)
+
+# ---------------------------------------------------------------------------
+# Install rules — headers + static libraries
+# ---------------------------------------------------------------------------
+# Install all public headers preserving directory structure.
+install(
+ DIRECTORY celeborn/
+ DESTINATION include/celeborn
+ FILES_MATCHING PATTERN "*.h"
+ PATTERN "tests" EXCLUDE
+)
+
+# Install the generated proto header.
+install(
+ FILES ${ProtoGenHeader}
+ DESTINATION include/celeborn/proto
+)
+
+# Install static libraries.
+install(
+ TARGETS client conf memory network proto protocol utils
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
diff --git a/cpp/celeborn/proto/CMakeLists.txt
b/cpp/celeborn/proto/CMakeLists.txt
index f83dafba8..00679bee9 100644
--- a/cpp/celeborn/proto/CMakeLists.txt
+++ b/cpp/celeborn/proto/CMakeLists.txt
@@ -14,4 +14,4 @@
# limitations under the License.
add_library(proto STATIC ${ProtoGenSource} ${ProtoGenHeader})
add_dependencies(proto generate_proto_source)
-target_link_libraries(proto ${Boost_LIBRARIES} ${PROTOBUF_LIBRARY})
+target_link_libraries(proto ${Boost_LIBRARIES} protobuf::libprotobuf)
diff --git a/cpp/celeborn/utils/CelebornUtils.h
b/cpp/celeborn/utils/CelebornUtils.h
index f79f329a5..6d39226ce 100644
--- a/cpp/celeborn/utils/CelebornUtils.h
+++ b/cpp/celeborn/utils/CelebornUtils.h
@@ -21,6 +21,7 @@
#include <google/protobuf/io/coded_stream.h>
#include <charconv>
#include <chrono>
+#include <set>
#include <vector>
#include "celeborn/memory/ByteBuffer.h"