Skip to content

[vcpkg]"default-features":false seems to just be ignored. Feature selection always adds default-features #35694

@Arech

Description

@Arech

Describe the bug
I might misunderstand something in vcpkg, but I though that according to the docs, "default-features": false should totally disable default feature set defined for a port and install only explicitly selected features. But it's not the case. Default-features are always selected and installed.

I have a private repository containing two ports:

  • X with two features: heavyA and lightB, and "default-features": [ "heavyA" ].
  • Y with several features, one of which, say "featureB" has
"dependencies": [
  {
    "name": "X",
    "default-features": false,
    "features": [ "lightB" ]
  }
]

I assumed that when manifest contains a dependency on port Y[featureB], then vcpkg must also install port X with feature lightB only, b/c default features, containing heavyA, are disabled. However, when building a software I noticed that port X installs both features, - heavyA (that should be disabled) and lightB. I've double checked everything and I can't find any potential source of dependency on feature heavyA of port X anywhere.

I was able to replicate that with publicly available ports:
opencv4 port contains a spectra of default-enabled features.

vcpkg depend-info opencv4
...
opencv4[default-features, webp, jpeg, dnn, png, quirc, tiff]: libjpeg-turbo, libpng, libwebp, ....

opencv4 has ffmpeg feature defined in a similar manner with restricted feature set:

 "ffmpeg": {
      "description": "ffmpeg support for opencv",
      "dependencies": [
        {
          "name": "ffmpeg",
          "default-features": false,
          "features": [
            "avcodec",
            "avformat",
            "swresample",
            "swscale"
          ]
        }
      ]
    },

By default ffmpeg port has these default features:

 "default-features": [
    "avcodec",
    "avdevice",
    "avfilter",
    "avformat",
    "swresample",
    "swscale"
  ],

So I assume that when I install opencv4[ffmpeg] only 4 specifically selected by opencv4 manifest's features must be present. However, it's not true:

vcpkg depend-info opencv4[ffmpeg]
...
ffmpeg[avfilter, avdevice, avcodec, avformat, swresample, swscale]: ......
...
opencv4[default-features, jpeg, dnn, ffmpeg, png, quirc, tiff, webp]: ffmpeg,  libjpeg-turbo, libpng, libwebp, ......

i.e. vcpkg fetches all default features for ffmpeg plus those additionally specified, and for opencv4 it also selects all default features plus ffmpeg feature as an addition, instead of using it exclusively.
(depend-info command is used to demonstrate the issue, the same is happening when vcpkg really install ports)

This seems like a bug to me. Documentation clearly states:

If the user wants to explicitly disable the default features, they can do so by adding "default-features": false to the dependency:

(see the bottom of the page)

Do I misunderstand something?

Environment
The same results in Windows 10:

>vcpkg --version
vcpkg package management program version 2023-11-16-4c1df40a3c5c5e18de299a99e9accb03c2a82e1e

>git log -1
commit b051c80d93fb023ce959622271e1183bff291fd5 (HEAD -> master, origin/master, origin/HEAD)
Author: ...
Date:   Wed Dec 6 03:41:09 2023 +0800

as well as on Ubuntu20.04 (in WSL with own vcpkg checkout, which hardly matters..)

$ ./vcpkg --version
vcpkg package management program version 2023-11-16-4c1df40a3c5c5e18de299a99e9accb03c2a82e1e

$ git log -1
commit e85cafa30def190eca0dc1413bf8c04e434af567 (HEAD -> master, origin/master, origin/HEAD)
Author: ...
Date:   Thu Nov 30 13:58:50 2023 -0800

Metadata

Metadata

Assignees

Labels

Stalecategory:vcpkg-bugThe issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions