build: generate flatbuffers headers at build time - #7488
Conversation
|
is there a fallback in case BuildFlatBuffers.cmake in not available? |
c43d945 to
a11d0c7
Compare
|
Hey @nilsnolde not realy but I wouldn't worry. Any distribution of flatbuffers includes this cmake file https://packages.debian.org/trixie/amd64/libflatbuffers-dev/filelist#:~:text=/usr/lib/x86_64%2Dlinux%2Dgnu/cmake/flatbuffers/BuildFlatBuffers.cmake It is required as many projects depend on it to autogenerate the targets based on their definitions. You probablly have it in your system if you install flatbuffers through your package manager |
a11d0c7 to
ee7170f
Compare
|
ah perfect, thanks @tete17 ! yeah, I was mainly worried about debian like distros. hmm, seems bookworm doesn't have it: https://packages.debian.org/bookworm/amd64/libflatbuffers-dev/filelist. it's EOL in a few months. since trixie is just a few weeks old, I'd strongly suggest to introduce a fall back. |
ee7170f to
fa8d75d
Compare
|
If this is pulled from vcpkg then there shouldn't be an issue on Debian bookworm, right? Or am I missing something here? |
|
IMO it's a bit nicer generally to not require vcpkg installations (always builds from source last I checked) and instead be able to use binary system packages for dependencies (except for win of course). I didn't really have the time to take a deeper look, I asked here if vcpkg is optional or required, but didn't get an answer yet. |
|
Hey @nilsnolde sorry for ignoring the questions. So regarding bookworm I have a strong suspecious, but I can't test it that, the flatbuffers team just restructure the cmake files and are now in a different place. If we wanted to support a debian based system based on bookworm (Ubutnu 22.04 for that matter as well) we would need to introduce an if clause in the cmake to include the right folder. Then again this would be to support an EOL operating system for native packages when they could just turn on the vcpkg integration and not worry about anything. Yes the initial cmake configure is annoyiong as it would take 1h in a medium system not going to lie but is a worth price to pay to ensure everybody uses the same library versions. |
|
I wouldn't worry too much about bookworm personally. It's |
fa8d75d to
f0d4b4b
Compare
|
yeah sorry, I read the trixie release wrong. and since vcpkg remains optional (as conan was), there's no real problem anyways. |
|
Once #7487 is done, this needs a rebase. One idea to make this reviewable independently could be to use the other PR's branch as the base. And then after it's done to change the base branch to master. |
f0d4b4b to
48792c8
Compare
Replace pre-committed generated headers with CMake build-time generation using flatbuffers_generate_headers() from the vcpkg flatbuffers package. This eliminates the need to pin flatbuffers to a specific version — any compatible flatc will regenerate the headers from the .fbs schemas during the build. - Add flatbuffers_generate_headers() call in CMakeLists.txt - Delete generated/ directory (pre-committed headers) - Remove flatbuffers 25.9.23 version override from vcpkg.json Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
48792c8 to
bd1ad70
Compare
The script managed git-subtree updates for vendored dependencies under third_party/. After Project-OSRM#7487 (vcpkg migration), Project-OSRM#7488 (flatbuffers from vcpkg), Project-OSRM#7495 (microtar -> libarchive), and Project-OSRM#7508 (vtzero unvendored via custom vcpkg overlay), third_party/ is empty and every entry the script knew how to update is now provided by vcpkg. Nothing left to manage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
.fbsschemas instead of committing pre-generated headersvcpkg.json— any compatible version now worksgenerated/directory (−1,800 lines of generated code)Why
The pre-committed
*_generated.hfiles contain astatic_assertchecking for an exact flatbuffers version match. This means every flatbuffers upgrade requires manually re-runningflatcand committing the results — a maintenance burden and source of version drift. With build-time generation, upgrading flatbuffers is just a vcpkg baseline bump.How it works
Uses
flatbuffers_generate_headers()from flatbuffers' ownBuildFlatBuffers.cmakemodule (shipped by vcpkg). This creates:GENERATE_osrm_fbsthat runsflatcwhen.fbsschemas changeosrm_fbswhose include directory points to the generated output${CMAKE_BINARY_DIR}/osrm_fbs/engine/api/flatbuffers/— same include path as before, no source changes neededTest plan
🤖 Generated with Claude Code