build: support system fmt dependency#2169
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Require kind labelWonderful, this rule succeeded.
🟢 Require version labelWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for using a system-installed fmt library instead of always downloading it via FetchContent. It adds a helper function vsag_target_has_header to verify if a target contains the required header, exposes a VSAG_USE_SYSTEM_FMT option, and updates the fmt configuration to search for the system package. Feedback suggests removing the redundant and cache-polluting find_path call in favor of relying solely on find_package, and adding a safety check in vsag_target_has_header to prevent checking the root directory when an include directory path is empty.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR extends VSAG’s CMake third-party dependency resolution to support using a system-provided fmt independently of the global VSAG_USE_SYSTEM_DEPS setting, including reuse of a parent project’s pre-existing fmt::fmt target and early validation of required headers.
Changes:
- Add
VSAG_USE_SYSTEM_FMTcache option as a per-dependency override. - Update
extern/fmt/fmt.cmaketo prefer pre-existing/systemfmt::fmtand fall back to bundled fmt when unavailable. - Introduce a CMake helper to validate that an imported/parent-provided target’s include dirs contain a required header.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| extern/fmt/fmt.cmake | Implements system/pre-existing fmt::fmt discovery with header validation and bundled fallback. |
| cmake/VSAGOptions.cmake | Adds VSAG_USE_SYSTEM_FMT option to control system fmt usage policy. |
| cmake/VSAGHelpers.cmake | Adds vsag_target_has_header() helper used for validating dependency targets. |
Reuse parent or system fmt targets while keeping bundled fallback behavior safe for incomplete installations. Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com> Assisted-by: OpenCode:gpt-5.5
6de59ac to
2eb9bc2
Compare
Summary
VSAG_USE_SYSTEM_FMTas a per-dependency override forVSAG_USE_SYSTEM_DEPS.fmt::fmttargets and fall back to bundled fmt whenAUTOcannot find a valid system header.ONinstead of breaking during compilation.Verification
make debug VSAG_USE_SYSTEM_DEPS=OFF EXTRA_DEFINED=\"-DVSAG_USE_SYSTEM_FMT=AUTO\"/home/xiangyu/vsag-system-fmt-superbuildwith parent-providedfmt::fmtand an executable linking bothvsagandfmt::fmt.