fix(cmake): osrm backend fetch content patch#7528
Open
ctriley wants to merge 1 commit intoProject-OSRM:masterfrom
Open
fix(cmake): osrm backend fetch content patch#7528ctriley wants to merge 1 commit intoProject-OSRM:masterfrom
ctriley wants to merge 1 commit intoProject-OSRM:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves OSRM’s CMake behavior when consumed as a subproject (via add_subdirectory() / FetchContent), aiming to keep standalone builds unchanged while reducing integration friction in superprojects that provide dependencies via package configs/imported targets.
Changes:
- Add
OSRM_BUILD_TESTINGandOSRM_BUILD_BENCHMARKS, defaulting toOFFfor subproject builds andONfor standalone builds. - Make dependency include-directory harvesting more provider-neutral (renaming internal variables and adding additional imported targets).
- Guard inclusion of FlatBuffers’
BuildFlatBuffers.cmakebased on whetherflatbuffers_generate_headersis already defined.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+426
to
+427
| flatbuffers::flatbuffers flatbuffers::libflatbuffers | ||
| TBB::tbb) |
Collaborator
|
The comment from our electric overlord seems to have a point. please have a look at the order of inclusion and discovery of tbb. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improve OSRM's CMake behavior when it is consumed as a subproject through
add_subdirectory()orFetchContent.This keeps the default standalone OSRM build behavior intact, while making the
library easier to embed in larger CMake projects that already provide
dependencies through standard package config files or imported targets.
Motivation
OSRM now primarily expects dependencies to come from vcpkg manifest mode, but
CMake superprojects often provide the same dependencies through other package
managers or pre-existing imported targets. In those builds, a few assumptions in
the current CMake setup make embedding OSRM harder than necessary:
flatbuffers_generate_headersdirectly rather than placing
BuildFlatBuffers.cmakenext to the config file.These are not OSRM source-level issues. They are CMake integration issues that
show up when OSRM is used as a library inside a larger build.
Changes
Add
OSRM_BUILD_TESTINGandOSRM_BUILD_BENCHMARKS.ONfor standalone OSRM builds.OFFwhen OSRM is included as a subproject.benchmark targets.
Make dependency include harvesting provider-neutral.
flatbuffers::libflatbuffersandTBB::tbb.Add LibArchive imported-target include propagation.
LibArchive::LibArchiveexposes include directories, add them toOSRM's dependency include list.
Guard FlatBuffers helper inclusion.
${flatbuffers_DIR}/BuildFlatBuffers.cmakewhenflatbuffers_generate_headersis not already defined.Why This Is Safe
For normal standalone OSRM builds, tests and benchmarks still default to being
included. Existing vcpkg-based builds continue to use the same package config
flow and the same imported targets.
For subproject builds, this reduces target graph pollution and avoids requiring
parent projects to patch OSRM just to prevent tests or benchmarks from being
configured. The include-directory changes are additive and only use properties
from targets that already exist.
Validation
v26.5.0.git diff --checkpasses.FetchContentwhile dependencies are supplied by package config/importedtargets.