Skip to content

build: migrate from Conan + vendored deps to vcpkg manifest mode - #7487

Merged
DennisOSRM merged 11 commits into
Project-OSRM:masterfrom
tete17:build/migrate-to-vcpkg
Apr 27, 2026
Merged

build: migrate from Conan + vendored deps to vcpkg manifest mode#7487
DennisOSRM merged 11 commits into
Project-OSRM:masterfrom
tete17:build/migrate-to-vcpkg

Conversation

@tete17

@tete17 tete17 commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrate osrm-backend's dependency management from the current three-path system (Conan 2.x + vendored third_party/ sources + system packages) to a single vcpkg manifest-mode setup. One dependency path on every platform, vendored copies deleted, CMakeLists simplified.

Why vcpkg over the status quo

The current setup has three parallel dependency paths that have diverged over time:

  • Conan for Windows/macOS CI, with ENABLE_CONAN gating a separate CMakeLists branch
  • System packages (apt-get, apk) for Linux CI and Docker, with custom Find modules
  • Vendored sources in third_party/ (flatbuffers, fmt, sol2, rapidjson, protozero, libosmium) as a fallback

This creates maintenance burden: dependency version bumps require touching 3+ places, the if(ENABLE_CONAN)/else() block in CMakeLists.txt has subtle differences (e.g., Lua 5.2 vs 5.4), and the vendored copies are perpetually stale.

vcpkg manifest mode collapses this into:

  • vcpkg.json — single source of truth for all dependency versions
  • vcpkg-configuration.json — pinned baseline for reproducibility
  • CMakePresets.json — cross-platform build configurations
  • One find_package() path in CMakeLists.txt — no more ENABLE_CONAN branching

Why vcpkg specifically

  • Microsoft-backed, large port registry — all OSRM dependencies (boost, tbb, expat, lua, flatbuffers, sol2, libosmium, etc.) are available
  • Manifest mode pins exact versions per-project with a baseline commit, avoiding "works on my machine" drift
  • Binary caching via GitHub Actions cache backend (x-gha,readwrite) — CI doesn't rebuild boost from source on every run
  • CMake-native — the toolchain file integrates transparently with find_package(), no wrapper scripts needed
  • Cross-platform — same workflow on Linux, macOS, Windows, and Docker with no platform-specific package install steps

What changes

Commit Description
1. build: add vcpkg manifest... vcpkg.json + vcpkg-configuration.json + CMakePresets.json
2. build: rewrite CMakeLists.txt... Single vcpkg-fed dep section, remove ENABLE_CONAN, add cmake/FindOsmium.cmake
3. build: remove vendored third_party... Delete third_party/{flatbuffers,fmt,libosmium,protozero,rapidjson,sol2} (−360k lines)
4. build: remove Conan Delete conanfile.py
5. ci: migrate CI workflows... Replace Conan/apt/brew steps with lukka/run-vcpkg@v11, add vcpkg-smoke.yml
6. build(docker): rewrite Dockerfiles... vcpkg in builder stage + Ninja + ccache + BuildKit cache mounts
7. docs: update build instructions README + Windows docs

Version pins (overrides in vcpkg.json)

  • sol2 → 3.3.1 — 3.5.0 breaks usertype_container with unordered_map<string,bool>
  • lua → 5.4.8 — Lua 5.5 removed LUA_ERRGCMM, incompatible with sol2 3.3.1
  • flatbuffers → 25.9.23 — generated headers in generated/ are pinned to this version

Docker build optimizations

  • Layer splitting: COPY vcpkg.jsonvcpkg installCOPY . /src so source-only changes skip the expensive dep layer
  • BuildKit cache mounts: vcpkg archives, downloads, and buildtrees persist across builds
  • Ninja instead of Make: lower scheduling overhead, ~10-20% faster
  • ccache with persistent cache mount: subsequent builds with small source changes hit ccache (50% cache hit rate on second build, improving over time)
  • Image size unchanged at ~331 MB (debian)

What stays vendored

  • third_party/microtar/ — single .c OBJECT library, no vcpkg port
  • third_party/vtzero/ — not in the vcpkg baseline used

Test plan

  • Local Linux build (configure + compile + all 7 binaries + --help smoke test)
  • Docker debian build (331 MB image, osrm-routed --help exits 0)
  • Docker rebuild with ccache warm (49s total, 7s compile, 50% ccache hit rate)
  • CI green on ubuntu-24.04, ubuntu-22.04, macos-15, windows-2025
  • Docker alpine build
  • Node.js bindings (npm install && npm test)

🤖 Generated with Claude Code

@tete17
tete17 force-pushed the build/migrate-to-vcpkg branch 4 times, most recently from 4131e76 to 43d6379 Compare April 17, 2026 18:20
@nilsnolde

Copy link
Copy Markdown
Contributor

can only say kudos :) I've been on/off working with vcpkg over quite some time as well and in 2026 it's definitely worth migrating. so much better than conan for most scenarios.

I didn't look: it's still optional right and fall back to system dependencies?

in case the docker optimizations are more scattered around, maybe it'd make sense to do that as a separate PR?

@tete17
tete17 force-pushed the build/migrate-to-vcpkg branch 5 times, most recently from c1aaf8d to 2b67c3f Compare April 20, 2026 09:45
@DennisOSRM

Copy link
Copy Markdown
Collaborator

does the switch have an impact on static linking of the binaries?

@tete17

tete17 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

Yes, mostly in a good direction.

Linux / macOS (x64-linux, x64-osx, arm64-osx): vcpkg's default triplets build everything static (.a). The resulting osrm-routed only dynamically links to system libs:

libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6, ld-linux

Boost, TBB, zlib, bz2, expat, lzma, zstd, lua, libxml2, osmium, protozero, flatbuffers runtime, abseil — all statically linked into the binary. This is actually more static than before: pre-vcpkg, TBB came from the system as libtbb.so, now it's bundled in.

Windows (x64-windows): vcpkg's default triplet builds DLLs. That's why src/nodejs/CMakeLists.txt copies the whole vcpkg_installed/x64-windows/bin/ next to node_osrm.node — Node's loader only finds DLLs in the same directory as the .node file. If we want Windows binaries self-contained too, switching to x64-windows-static (or -static-md) is a one-line change in CMakePresets.json; happy to do that as a follow-up if preferred.

@DennisOSRM

Copy link
Copy Markdown
Collaborator

Fully static binaries would be preferred. Tbb is a bit of a borderline case which could be static or dynamic.

@tete17
tete17 force-pushed the build/migrate-to-vcpkg branch from 2b67c3f to 077e7bc Compare April 20, 2026 10:49
@tete17

tete17 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

Switched Windows to x64-windows-static-md (static libs + dynamic CRT — the dynamic CRT is required for the Node.js addon to be ABI-compatible with node.exe, which itself is built with /MD). The WIN32 block in src/nodejs/CMakeLists.txt that copied vcpkg_installed/bin/ next to node_osrm.node is gone since there are no DLLs to ship anymore.

TBB stays static (vcpkg builds it static on all our triplets now). Force-pushed, CI will tell us if anything breaks on Windows with the static linkage.

@DennisOSRM

DennisOSRM commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Gave the PR a first round of scrutiny. Generally speaking I think this looks good. I will post a couple of comments later on a number of smaller touch ups and changes.

Looks like we should be able to get this merged before the next monthly release.

@tete17

tete17 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

can only say kudos :) I've been on/off working with vcpkg over quite some time as well and in 2026 it's definitely worth migrating. so much better than conan for most scenarios.

I didn't look: it's still optional right and fall back to system dependencies?

in case the docker optimizations are more scattered around, maybe it'd make sense to do that as a separate PR?

Sorry @nilsnolde I let claude code anwser and your second paragraph slipped through. Yes indeed the vcpkg integration is always optional. By default it will try to pick up the system packages. You may need to tweak a bit the cmake presets but it should be no problem

@DennisOSRM DennisOSRM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a first round of comments. I think this is already pretty close to being mergeable. It seems the major remaining piece is back porting the lua5.5 compatibility patch. Pinning old versions of sol2 and lua seems subpar. The other comments should be pretty easy to fix.

All in all, good work! We are close.

Comment thread .github/workflows/osrm-backend.yml Outdated
Comment thread src/tools/contract.cpp Outdated
Comment thread src/tools/customize.cpp
Comment thread src/tools/extract.cpp Outdated
Comment thread src/tools/partition.cpp Outdated
Comment thread src/tools/store.cpp Outdated
Comment thread vcpkg-overlay-ports/sol2/fix-noexcept-lua-cfunction.patch
Comment thread CMakeLists.txt Outdated
Comment thread vcpkg.json
Comment thread vcpkg.json
@tete17
tete17 force-pushed the build/migrate-to-vcpkg branch 4 times, most recently from ca78f9a to bb57f60 Compare April 21, 2026 09:45
@tete17
tete17 requested a review from DennisOSRM April 21, 2026 09:45
@tete17
tete17 force-pushed the build/migrate-to-vcpkg branch 2 times, most recently from c25686f to 8611320 Compare April 21, 2026 12:02
@DennisOSRM

Copy link
Copy Markdown
Collaborator

I gave this a test run on macOS 15 (X64) today using AppleClang 17. A couple of things seem to be not fully stable yet. The cmake bootstrapping runs at glacial pace. What used to be seconds is now a minute or more. Also, the bootstrapping does not complete. These issue block moving this PR further right now:

cmake .. -GNinja
-- The C compiler identification is AppleClang 17.0.0.17000013
-- The CXX compiler identification is AppleClang 17.0.0.17000013
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No build type specified, defaulting to Release
-- Configuring OSRM in release mode
-- Performing Test SUPPORTS_CXXFLAG_all
-- Performing Test SUPPORTS_CXXFLAG_all - Success
-- Performing Test SUPPORTS_CFLAG_all
-- Performing Test SUPPORTS_CFLAG_all - Success
-- Performing Test SUPPORTS_CXXFLAG_extra
-- Performing Test SUPPORTS_CXXFLAG_extra - Success
-- Performing Test SUPPORTS_CFLAG_extra
-- Performing Test SUPPORTS_CFLAG_extra - Success
-- Performing Test SUPPORTS_CXXFLAG_pedantic
-- Performing Test SUPPORTS_CXXFLAG_pedantic - Success
-- Performing Test SUPPORTS_CFLAG_pedantic
-- Performing Test SUPPORTS_CFLAG_pedantic - Success
-- Performing Test SUPPORTS_CXXFLAG_error
-- Performing Test SUPPORTS_CXXFLAG_error - Success
-- Performing Test SUPPORTS_CFLAG_error
-- Performing Test SUPPORTS_CFLAG_error - Success
-- Performing Test SUPPORTS_CXXFLAG_suggest_override
-- Performing Test SUPPORTS_CXXFLAG_suggest_override - Success
-- Performing Test SUPPORTS_CFLAG_suggest_override
-- Performing Test SUPPORTS_CFLAG_suggest_override - Success
-- Performing Test SUPPORTS_CXXFLAG_suggest_destructor_override
-- Performing Test SUPPORTS_CXXFLAG_suggest_destructor_override - Success
-- Performing Test SUPPORTS_CFLAG_suggest_destructor_override
-- Performing Test SUPPORTS_CFLAG_suggest_destructor_override - Success
-- Performing Test SUPPORTS_CXXFLAG_unused
-- Performing Test SUPPORTS_CXXFLAG_unused - Success
-- Performing Test SUPPORTS_CFLAG_unused
-- Performing Test SUPPORTS_CFLAG_unused - Success
-- Performing Test SUPPORTS_CXXFLAG_unreachable_code
-- Performing Test SUPPORTS_CXXFLAG_unreachable_code - Success
-- Performing Test SUPPORTS_CFLAG_unreachable_code
-- Performing Test SUPPORTS_CFLAG_unreachable_code - Success
-- Performing Test SUPPORTS_CXXFLAG_delete_incomplete
-- Performing Test SUPPORTS_CXXFLAG_delete_incomplete - Success
-- Performing Test SUPPORTS_CFLAG_delete_incomplete
-- Performing Test SUPPORTS_CFLAG_delete_incomplete - Success
-- Performing Test SUPPORTS_CXXFLAG_duplicated_cond
-- Performing Test SUPPORTS_CXXFLAG_duplicated_cond - Failed
-- Performing Test SUPPORTS_CFLAG_duplicated_cond
-- Performing Test SUPPORTS_CFLAG_duplicated_cond - Failed
-- Flag -Wduplicated-cond is unsupported
-- Flag -Wduplicated-cond is unsupported
-- Performing Test SUPPORTS_CXXFLAG_disabled_optimization
-- Performing Test SUPPORTS_CXXFLAG_disabled_optimization - Success
-- Performing Test SUPPORTS_CFLAG_disabled_optimization
-- Performing Test SUPPORTS_CFLAG_disabled_optimization - Success
-- Performing Test SUPPORTS_CXXFLAG_init_self
-- Performing Test SUPPORTS_CXXFLAG_init_self - Success
-- Performing Test SUPPORTS_CFLAG_init_self
-- Performing Test SUPPORTS_CFLAG_init_self - Success
-- Performing Test SUPPORTS_CXXFLAG_bool_compare
-- Performing Test SUPPORTS_CXXFLAG_bool_compare - Failed
-- Performing Test SUPPORTS_CFLAG_bool_compare
-- Performing Test SUPPORTS_CFLAG_bool_compare - Failed
-- Flag -Wbool-compare is unsupported
-- Flag -Wbool-compare is unsupported
-- Performing Test SUPPORTS_CXXFLAG_logical_not_parentheses
-- Performing Test SUPPORTS_CXXFLAG_logical_not_parentheses - Success
-- Performing Test SUPPORTS_CFLAG_logical_not_parentheses
-- Performing Test SUPPORTS_CFLAG_logical_not_parentheses - Success
-- Performing Test SUPPORTS_CXXFLAG_logical_op
-- Performing Test SUPPORTS_CXXFLAG_logical_op - Failed
-- Performing Test SUPPORTS_CFLAG_logical_op
-- Performing Test SUPPORTS_CFLAG_logical_op - Failed
-- Flag -Wlogical-op is unsupported
-- Flag -Wlogical-op is unsupported
-- Performing Test SUPPORTS_CXXFLAG_misleading_indentation
-- Performing Test SUPPORTS_CXXFLAG_misleading_indentation - Success
-- Performing Test SUPPORTS_CFLAG_misleading_indentation
-- Performing Test SUPPORTS_CFLAG_misleading_indentation - Success
-- Performing Test SUPPORTS_CXXFLAG_no_return_local_addr
-- Performing Test SUPPORTS_CXXFLAG_no_return_local_addr - Success
-- Performing Test SUPPORTS_CFLAG_no_return_local_addr
-- Performing Test SUPPORTS_CFLAG_no_return_local_addr - Success
-- Performing Test SUPPORTS_CXXFLAG_odr
-- Performing Test SUPPORTS_CXXFLAG_odr - Success
-- Performing Test SUPPORTS_CFLAG_odr
-- Performing Test SUPPORTS_CFLAG_odr - Success
-- Performing Test SUPPORTS_CXXFLAG_pointer_arith
-- Performing Test SUPPORTS_CXXFLAG_pointer_arith - Success
-- Performing Test SUPPORTS_CFLAG_pointer_arith
-- Performing Test SUPPORTS_CFLAG_pointer_arith - Success
-- Performing Test SUPPORTS_CXXFLAG_redundant_decls
-- Performing Test SUPPORTS_CXXFLAG_redundant_decls - Success
-- Performing Test SUPPORTS_CFLAG_redundant_decls
-- Performing Test SUPPORTS_CFLAG_redundant_decls - Success
-- Performing Test SUPPORTS_CXXFLAG_reorder
-- Performing Test SUPPORTS_CXXFLAG_reorder - Success
-- Performing Test SUPPORTS_CFLAG_reorder
-- Performing Test SUPPORTS_CFLAG_reorder - Success
-- Performing Test SUPPORTS_CXXFLAG_shift_negative_value
-- Performing Test SUPPORTS_CXXFLAG_shift_negative_value - Success
-- Performing Test SUPPORTS_CFLAG_shift_negative_value
-- Performing Test SUPPORTS_CFLAG_shift_negative_value - Success
-- Performing Test SUPPORTS_CXXFLAG_sizeof_array_argument
-- Performing Test SUPPORTS_CXXFLAG_sizeof_array_argument - Success
-- Performing Test SUPPORTS_CFLAG_sizeof_array_argument
-- Performing Test SUPPORTS_CFLAG_sizeof_array_argument - Success
-- Performing Test SUPPORTS_CXXFLAG_switch_bool
-- Performing Test SUPPORTS_CXXFLAG_switch_bool - Success
-- Performing Test SUPPORTS_CFLAG_switch_bool
-- Performing Test SUPPORTS_CFLAG_switch_bool - Success
-- Performing Test SUPPORTS_CXXFLAG_tautological_compare
-- Performing Test SUPPORTS_CXXFLAG_tautological_compare - Success
-- Performing Test SUPPORTS_CFLAG_tautological_compare
-- Performing Test SUPPORTS_CFLAG_tautological_compare - Success
-- Performing Test SUPPORTS_CXXFLAG_trampolines
-- Performing Test SUPPORTS_CXXFLAG_trampolines - Failed
-- Performing Test SUPPORTS_CFLAG_trampolines
-- Performing Test SUPPORTS_CFLAG_trampolines - Failed
-- Flag -Wtrampolines is unsupported
-- Flag -Wtrampolines is unsupported
-- Performing Test SUPPORTS_CXXFLAG_no_deprecated_comma_subscript
-- Performing Test SUPPORTS_CXXFLAG_no_deprecated_comma_subscript - Success
-- Performing Test SUPPORTS_CFLAG_no_deprecated_comma_subscript
-- Performing Test SUPPORTS_CFLAG_no_deprecated_comma_subscript - Success
-- Performing Test SUPPORTS_CXXFLAG_no_comma_subscript
-- Performing Test SUPPORTS_CXXFLAG_no_comma_subscript - Failed
-- Performing Test SUPPORTS_CFLAG_no_comma_subscript
-- Performing Test SUPPORTS_CFLAG_no_comma_subscript - Failed
-- Flag -Wno-comma-subscript is unsupported
-- Flag -Wno-comma-subscript is unsupported
-- Performing Test SUPPORTS_CXXFLAG_no_ambiguous_reversed_operator
-- Performing Test SUPPORTS_CXXFLAG_no_ambiguous_reversed_operator - Success
-- Performing Test SUPPORTS_CFLAG_no_ambiguous_reversed_operator
-- Performing Test SUPPORTS_CFLAG_no_ambiguous_reversed_operator - Success
-- Performing Test SUPPORTS_CXXFLAG_no_restrict
-- Performing Test SUPPORTS_CXXFLAG_no_restrict - Failed
-- Performing Test SUPPORTS_CFLAG_no_restrict
-- Performing Test SUPPORTS_CFLAG_no_restrict - Failed
-- Flag -Wno-restrict is unsupported
-- Flag -Wno-restrict is unsupported
-- Performing Test SUPPORTS_CXXFLAG_no_free_nonheap_object
-- Performing Test SUPPORTS_CXXFLAG_no_free_nonheap_object - Success
-- Performing Test SUPPORTS_CFLAG_no_free_nonheap_object
-- Performing Test SUPPORTS_CFLAG_no_free_nonheap_object - Success
-- Performing Test SUPPORTS_CXXFLAG_no_unneeded_internal_declaration
-- Performing Test SUPPORTS_CXXFLAG_no_unneeded_internal_declaration - Success
-- Performing Test SUPPORTS_CFLAG_no_unneeded_internal_declaration
-- Performing Test SUPPORTS_CFLAG_no_unneeded_internal_declaration - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test OSRM_HAS_STD_FORMAT
-- Performing Test OSRM_HAS_STD_FORMAT - Success
-- Performing Test SUPPORTS_CXXFLAG_no_unused_variable
-- Performing Test SUPPORTS_CXXFLAG_no_unused_variable - Success
-- Performing Test SUPPORTS_CXXFLAG_no_format
-- Performing Test SUPPORTS_CXXFLAG_no_format - Success
CMake Error at CMakeLists.txt:347 (find_package):
  Could not find a package configuration file provided by "RapidJSON" with
  any of the following names:

    RapidJSON.cps
    rapidjson.cps
    RapidJSONConfig.cmake
    rapidjson-config.cmake

  Add the installation prefix of "RapidJSON" to CMAKE_PREFIX_PATH or set
  "RapidJSON_DIR" to a directory containing one of the above files.  If
  "RapidJSON" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!

@DennisOSRM

Copy link
Copy Markdown
Collaborator

The glacial pace issue seemed unrelated, and I was able to fix this. The RapidJSON issue remains. It could be something about platform triples, but not 100% sure.

@tete17

tete17 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

Hi @DennisOSRM

I don't have a mac with me to test but I suspect you may not have enabled the vcpkg integration since RapidJSON should be comming straight from the vcpkg install and the mac os runners of github work.

Can I ask of a few things:

  1. To delete the build folder of your mac system
  2. Share what your $VCPKG_ROOT env looks like
  3. Run cmake --preset release

This should hopefully clear things out.

@DennisOSRM

DennisOSRM commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

I was able to resolve the issue. In the end, it came down to a broken CMakeUserPresets.json in directory. Removed it, ran bootstrap using cmake —preset release, again, and then as able to build everything as expected. I had to remove locally installed boost, tho.

There's a minor annoyance when building on macOS (arm as well as X64):

[98/114] Linking CXX executable unit_tests/contractor-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libboost_iostreams.a', 'vcpkg_installed/x64-osx/lib/libboost_thread.a', 'vcpkg_installed/x64-osx/lib/libtbb.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[99/114] Linking CXX executable unit_tests/engine-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[101/114] Linking CXX executable unit_tests/partitioner-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a'
[102/114] Linking CXX executable unit_tests/updater-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[105/114] Linking CXX executable unit_tests/customizer-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libboost_iostreams.a', 'vcpkg_installed/x64-osx/lib/libboost_thread.a', 'vcpkg_installed/x64-osx/lib/libtbb.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[107/114] Linking CXX executable unit_tests/library-customize-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libz.a'
[108/114] Linking CXX executable unit_tests/library-contract-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libz.a'
[109/114] Linking CXX executable unit_tests/extractor-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/debug/lib/libbz2d.a', 'vcpkg_installed/x64-osx/debug/lib/libexpat.a', 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libbz2.a', 'vcpkg_installed/x64-osx/lib/libexpat.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[111/114] Linking CXX executable unit_tests/util-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[112/114] Linking CXX executable unit_tests/server-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libz.a'
[113/114] Linking CXX executable unit_tests/library-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/lib/libboost_date_time.a', 'vcpkg_installed/x64-osx/lib/libz.a'
[114/114] Linking CXX executable unit_tests/library-extract-tests
ld: warning: ignoring duplicate libraries: 'vcpkg_installed/x64-osx/debug/lib/libbz2d.a', 'vcpkg_installed/x64-osx/debug/lib/libexpat.a', 'vcpkg_installed/x64-osx/lib/libbz2.a', 'vcpkg_installed/x64-osx/lib/libexpat.a', 'vcpkg_installed/x64-osx/lib/libz.a'

This should not block us from moving forward, tho.

The branch needs a final rebase/merge to fix the merge conflict, and then we are ready to go. 🚀

@DennisOSRM DennisOSRM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job. This PR is not an insignificant achievement. 👍 Thanks for the contribution.

@DennisOSRM

Copy link
Copy Markdown
Collaborator

There's a small issue on GCC 15.2.0 (Ubuntu 26.04) where LTO doesn't work in one of the unit tests. I had to circumvent this with the following patch:

diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt
index 0a4840580..99cfdf57d 100644
--- a/unit_tests/CMakeLists.txt
+++ b/unit_tests/CMakeLists.txt
@@ -124,6 +124,11 @@ add_executable(util-tests
        ${UtilTestsSources}
         $<TARGET_OBJECTS:UTIL> $<TARGET_OBJECTS:MICROTAR>)
 
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
+    # TODO: remove after we stop supporting GCC 15, or when the false positive is fixed in GCC 15.
+    set_property(TARGET util-tests PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
+endif()
+
 # vcpkg builds boost statically on every platform, so BOOST_TEST_DYN_LINK
 # must never be defined — the dyn-link path expects a different
 # unit_test_main() signature than the static library exports, and enabling

This should be the final change after resolving the merge conflict.

tete17 and others added 11 commits April 27, 2026 15:43
Introduce vcpkg manifest mode as the single dependency management
strategy. The manifest pins all dependencies with a baseline commit
and a single version override for flatbuffers (25.9.23) to match the
committed generated headers. sol2 comes from an overlay port, and
Lua stays at the baseline — Lua 5.5 compat lives in the sol2 overlay
as a patch.

CMakePresets.json provides cross-platform build presets (release,
debug, asan, CI variants for Linux/macOS/Windows) that wire up the
vcpkg toolchain file automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the dual ENABLE_CONAN/system-packages dependency resolution
with a single vcpkg-based path. All find_package() calls now consume
vcpkg CONFIG-mode packages or standard CMake modules.

Key changes:
- Remove ENABLE_CONAN option and entire if/else dependency block
- Remove flatbuffers add_subdirectory (now a vcpkg package)
- Remove vendored include_directories for libs moved to vcpkg
- Add cmake/FindOsmium.cmake (extracted from third_party/libosmium)
  with patched protozero detection for vcpkg's header-only port
- Wire up modern imported targets (Boost::*, TBB::tbb, etc.)
- Harvest INTERFACE_INCLUDE_DIRECTORIES from header-only targets
  for legacy code that reads Boost/TBB include path variables
- Update Node.js CMakeLists.txt to use TBB::tbb imported target

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Delete third_party/{flatbuffers,fmt,libosmium,protozero,rapidjson,sol2}
— all are now consumed as vcpkg packages. The remaining third_party/
contents (microtar, vtzero) stay vendored as they have no vcpkg port.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Delete conanfile.py — Conan is fully replaced by vcpkg manifest mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace all Conan install steps with lukka/run-vcpkg@v11
- Remove manual Boost, TBB, and system library install steps
- Add vcpkg binary cache via GitHub Actions cache backend
- Rename matrix entries from conan-* to vcpkg-*
- Add vcpkg-smoke.yml for non-gating manifest resolution check
- Update windows-build.bat to use cmake --preset ci-windows
- Update UBSan suppressions for vcpkg include paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace apt-get/apk system dependency installation with vcpkg
bootstrap in the builder stage. Key optimizations:

- Split vcpkg install into its own layer (cached when manifest
  unchanged, source-only changes skip the expensive dep build)
- BuildKit cache mounts for vcpkg archives, downloads, and buildtrees
  persist across docker build invocations on the host
- Switch from Make to Ninja for lower scheduling overhead
- Add ccache with a persistent cache mount for C++ compilation,
  dramatically speeding up rebuilds with small source changes
- Keep VCPKG_ROOT=/vcpkg (outside /opt) so the runstage COPY
  doesn't drag the ~5 GB vcpkg tree into the final image

Image size remains ~331 MB (debian) with only TBB shared libs
copied to the runstage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace Conan and system-package build instructions with vcpkg
workflow in README and Windows dependency documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two separate caching gaps were making every CI run rebuild all 113 ports
from scratch:

1. The x-gha binary caching backend has been removed in the vcpkg version
   we pin (c3867e714). VCPKG_BINARY_SOURCES=clear;x-gha,readwrite was a
   no-op, vcpkg printed a warning and built everything from source.

   Switch to the files backend pointing at a workspace directory, and
   persist that directory across runs with actions/cache@v5. Cache key
   includes hashes of vcpkg.json, vcpkg-configuration.json, and the
   overlay ports tree so port changes invalidate.

2. Docker builds used BuildKit --mount=type=cache, which only persists on
   the same runner — on ephemeral GHA runners that means no cache hits.

   Replace raw 'docker build' with docker/build-push-action@v6 + buildx
   configured with cache-to/cache-from=type=gha. Scoped per base image
   so debian and alpine don't collide.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bookworm ships cmake 3.25, but vcpkg's lua 5.5.0 port now requires
cmake_minimum_required(VERSION 3.31), so `docker build` fails at
vcpkg's configure step for lua. Trixie ships cmake 3.31.6 and is
the current stable Debian, which is the distro we support.

This is a side-effect of dropping the lua 5.4.8 override in the
vcpkg manifest — previously we pinned to a version whose port
tolerated older cmake, so the Dockerfile's apt cmake (3.25) was
enough.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Works around a GCC 15 false positive that breaks LTO for util-tests.
Patch suggested by @DennisOSRM in PR review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tete17
tete17 force-pushed the build/migrate-to-vcpkg branch from 8611320 to 84fb898 Compare April 27, 2026 13:47
@tete17

tete17 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

Hey @DennisOSRM thanks for the feedback. I pushed another commit

My employee is planning to use this more extensive so why not contribute back 😄 as a way to pay back for all the effort made into this

@DennisOSRM
DennisOSRM merged commit 85fbefa into Project-OSRM:master Apr 27, 2026
26 checks passed
@tete17
tete17 deleted the build/migrate-to-vcpkg branch April 27, 2026 15:48
tete17 added a commit to tete17/osrm-backend that referenced this pull request May 4, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants