vcpkg

VCPKG adding conditional dependency


I have a custom port that can require 1 of 4 incompatible dependencies, Is there a way to sensibly do this using VCPKG? So that it is clear in the .json why I am using a particular dependency?

Where I have 2 alternate bare-metal dependencies that can change based on the exact arm processor used.

And I have the 3rd/4th option which are on an rtos platform using 1/2 different arm processors.

"name": "some-dependency"
"version": "0.4.0",
"dependencies": [
   "dep1",
   {
      "name": "dep2a",
      "platform" : "bare-metal & cortex-a7" // Something like this would be nice, but doesn't work.
   },
   {
      "name": "dep2b",
      "platform" : "bare-metal & cortex-a8" //Something like this would be nice, but doesn't work.
   },
   {
      "name": "dep2c",
      "platform" : "freertos"
   },
   {
     "name": "vcpkg-cmake",
     "host": true
   },
   {
     "name": "vcpkg-cmake-config",
     "host": true
   }
]


Solution

  • There's a triplet variable VCPKG_DEP_INFO_OVERRIDE_VARS (docs) that allows you to override the default set of terms used for platform expression evaluation.

    In custom triplet:

    set(VCPKG_DEP_INFO_OVERRIDE_VARS "bare-metal;cortex-a7")
    

    In vcpkg manifest:

    "dependencies": [
      {
        "name": "dep2a",
        "platform" : "bare-metal & cortex-a7"
      }
    ]
    

    PS: I've assumed that you've meant bare-metal & cortex-a7 instead of bare-metal | coretex-a7. If not, just drop bare-metal from the triplet.