You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Adopt a "submodule-first, FetchContent-fallback" approach for third‑party deps.
- Add and pin submodules under 3rdparty: spdlog, fmt, httplib, skywalking-data-collect-protocol, grpc (pinned tags included).
- Move auto-detection and conflict validation into each dependency module (cmake/*.cmake) and simplify top-level CMakeLists.txt.
- Update CI (main.yml) to checkout submodules and to build gRPC from grpc.
- Add skywalking.cmake and wire proto2cpp to use SKYWALKING_PROTOCOL_PATH.
- Update README.md with submodule workflow, build instructions and bump procedure.
Rationale: improves reproducibility, makes dependency handling explicit and easier to maintain.
Signed-off-by: Matthieu MOREL <[email protected]>
This repository pins several third-party dependencies under `3rdparty/` (example: `spdlog`, `fmt`, `httplib`, `skywalking-data-collect-protocol`). The top-level CMake will auto-detect these submodules and use them via `add_subdirectory()`.
46
+
47
+
- FetchContent fallback (automatic clone at configure time):
48
+
49
+
If a submodule is not present, CMake can automatically download the dependency at configure time using FetchContent. This is controlled by CMake options of the form `-D<LIB>_FETCHCONTENT=ON`.
50
+
51
+
Important: this project now defaults `*_FETCHCONTENT` to `OFF` to favour a submodule-first workflow (reproducible builds). Each dependency module will auto-detect a local `3rdparty/<lib>` submodule and, unless you explicitly set the corresponding `-D` option, enable the submodule and only enable FetchContent as a fallback when the submodule is absent.
52
+
53
+
If you need to force FetchContent for any dependency (for example, to debug or when you prefer not to initialize submodules), you can pass `-D<LIB>_FETCHCONTENT=ON` on the `cmake` command line. If you pass conflicting options (both `-D<LIB>_AS_SUBMODULE=ON` and `-D<LIB>_FETCHCONTENT=ON`) CMake will stop with a helpful error and you must choose one.
54
+
55
+
For SkyWalking you can enable FetchContent with:
56
+
57
+
```bash
58
+
cmake -DSKYWALKING_FETCHCONTENT=ON -S . -B build
59
+
cmake --build build
60
+
```
61
+
62
+
- Explicit path (developer workflow):
63
+
64
+
If you already have a local checkout of `skywalking-data-collect-protocol`, point CMake to it:
Most third-party dependencies follow the same pattern: prefer the pinned submodule under `3rdparty/` (submodule-first) and fall back to `FetchContent` at configure time when the submodule is not present. See the top-level `CMakeLists.txt` and the modules in `cmake/` for details.
74
+
75
+
There are two cases worth calling out because their consumption/build steps differ slightly:
76
+
77
+
- gRPC
78
+
79
+
gRPC is not header-only and typically needs configuration and a build step (or its targets must be available via `find_package`). This repository includes a pinned copy of gRPC at `3rdparty/grpc` (tag `v1.74.1`) so builds are reproducible. CI is configured to build gRPC from that submodule.
80
+
81
+
To build gRPC locally from the submodule and install it for the rest of the project:
If you prefer not to use the submodule you can still clone and build gRPC separately and make its CMake targets available to the project, but using the pinned submodule is recommended for reproducibility.
101
+
102
+
- skywalking-data-collect-protocol (protobufs)
103
+
104
+
The SkyWalking protocol repository contains the protobuf definitions used to generate code for the project. The `cmake/skywalking.cmake` module sets `SKYWALKING_PROTOCOL_PATH` when the `3rdparty/skywalking-data-collect-protocol` submodule is present so the proto generation step can locate the `.proto` files.
105
+
106
+
You can override that behavior by supplying an explicit path:
Alternatively, enable FetchContent for SkyWalking with `-DSKYWALKING_FETCHCONTENT=ON` to let CMake fetch the proto repo at configure time.
114
+
115
+
How to bump a submodule (example for skywalking-data-collect-protocol):
116
+
```bash
117
+
cd 3rdparty/skywalking-data-collect-protocol
118
+
git fetch --tags
119
+
git checkout tags/v10.4.0 # or a specific commit
120
+
cd ../..
121
+
git add 3rdparty/skywalking-data-collect-protocol
122
+
git commit -m "Pin skywalking-data-collect-protocol to v10.4.0"
123
+
git push
43
124
```
44
125
126
+
If you prefer CI to always fetch the latest submodules, ensure the workflow initializes submodules (this repo's CI uses `actions/checkout` with `submodules: 'recursive'`).
127
+
45
128
You can also use find_package to get target libary in your project. Like this:
0 commit comments