microsoft / vcpkg-docs

MIT License
50 stars 66 forks source link

Specific Boost version for transitive dependencies #283

Open ipiqueras opened 6 months ago

ipiqueras commented 6 months ago

Type of issue

Missing information

Description

I'm reading how to install a specific version for Boost libraries and, it works fine.

What is not described is how to consume a port, in a private registry, that depends on a specific version of Boost. Say that you have a port foo that depends on some old Boost 1.76.0.

So far I have tried using vcpkg-configuration property in ports/foo/portfile.cmake and, setting a baseline there:

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
  "name": "foo",
  "version": "1.0.0",
  "port-version": 0,
  "supports": "!(windows) & (arm32 | arm64 | x64 | x86)",
  "dependencies": [
      {"name": "boost-filesystem", "platform": "native"}
  ],
  "vcpkg-configuration": {
    "registries": [
      {
        "kind": "git",
        "repository": "https://github.com/Microsoft/vcpkg",
        "baseline": "761c81d43335a5d5ccc2ec8ad90bd7e2cbba734e",
        "packages": [ "boost*", "boost-*"]
      }
    ]
  }
}

In the consuming project (let's call it bar):

> vcpkg install --overlay-ports=/path/to/ports/foo
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...

The "Fetching registry information from" is only printed once and, uses the baseline configured for the registry in bar , which brings newer Boost versions.

I also tried a combination of vcpkg-configuration and overrides, without success.

Page URL

https://learn.microsoft.com/en-us/vcpkg/consume/boost-versions

Content source URL

https://github.com/Microsoft/vcpkg-docs/blob/main/vcpkg/consume/boost-versions.md

Document Version Independent Id

efdb8438-0860-24e8-c015-44fda7053a6a

Article author

@vicroms

Metadata

vicroms commented 6 months ago

@ipiqueras let me know if I understood correctly.

If that's the case, then the vcpkg-configuration on foo is ignored and that is by design.

vcpkg only reads configuration from the top-level manifest (vpckg.json). You have to add the old-Boost baseline registry in a vcpkg-configuration.json file in your project's (bar's) directory or set the registries in bar's vcpkg-configuration object.

patrikhuber commented 1 month ago

Can't you, in foo's vcpkg.json, just do:

"dependencies": [
      {"name": "boost-filesystem", "version==": "1.76.0", "platform": "native"}
  ]

? Or maybe using an "override" - looks like the situation is a lot more complicated (https://devblogs.microsoft.com/cppblog/take-control-of-your-vcpkg-dependencies-with-versioning-support/) but that blog post should help you. It also mentions that overrides are not transitive so perhaps that means you need to add an override to bar's, not to foo's vcpkg.json (which is counter-intuitive to me, but oh well).