This document will teach you how to set versions of meta-packages like `boost` or `qt5`.
**What is a meta-package?**
In vcpkg we call meta-packages to ports that by themselves don't install anything but that instead forward installation to another port or ports. The reasons for these meta-packages to exist are plenty: to install different versions of a library depending on platform (like the old OpenSSL port did), to allow for multiple versions to exist in the vcpkg registry at the same time (OpenCV), or to conveniently install/uninstall a catalog of related packages (Boost and Qt).
In the case of Boost, it is unlikely that a user requires all of the 140+ Boost libraries in their project. For the sake of convenience, vcpkg splits Boost into multiple sub-packages broken down to individual libraries. By doing so, users can limit the subset of Boost libraries that they depend on.
If a user wants to install all of the Boost libraries available in vcpkg, they can do so by installing the `boost` meta-package.
Due to the nature of meta-packages, some unexpected issues arise when trying to use them with versioning. If a user writes the following manifest file:
It is reasonable to expect that overriding `boost` to version 1.72.0 results in all Boost packages being pinned to version 1.72.0. **However, vcpkg does not treat the `boost` meta-package any differently that any other port.** In other words, vcpkg has no notion that `boost` is related to all the other `boost-*` libraries, other than it depends on all of them. For this reason, all the other boost packages are installed at version 1.75.0, which is the baseline version.
Below, we describe two methods to pin down Boost versions effectively.
## Method 1: Pin specific packages
Use `"overrides"` to force specific versions in a package-by-package basis.
This method allows you to quickly set the specific versions you want, but you will need to write an override for each package. Boost libraries are also heavily interdependent, which means that you may end up writing a lot of override lines.
The second method makes it easy to pin the entire Boost collection and end up with a very simple manifest file.
## Method 2: Modify baseline
An easy way to set the version for the entirety of boost is to use the `"builtin-baseline"` property.
As of right now, it is only possible to go back to Boost version `1.75.0` using a baseline. Since that was the contemporary Boost version when the versioning feature was merged. **But, it is possible to modify the baseline to whatever you like and use that instead.**
### Step 1: Create a new branch
As described in the versioning documentation. The value that goes in `"builtin-baseline"` is a Git commit in the vcpkg repository's history. Then it stands to reason, that if you want to customize the baseline you should be able to create a new commit with said custom baseline.
Let's start by creating a new branch to hold our modified baseline.
In the directory containing your clone of the vcpkg Git repository run:
```
git checkout -b custom-boost-baseline
```
This will create a new branch named `custom-boost-baseline` and check it out immediately.
### Step 2: Modify the baseline
The next step is to modify the baseline file, open the file in your editor of choice and modify the entries for the Boost libraries.
Change the `"baseline"` version to your desired version.
_NOTE: Remember to also set the port versions to 0 (or your desired version)._
`${vcpkg-root}/versions/baseline.json`
```diff
...
"boost": {
- "baseline": "1.75.0",
+ "baseline": "1.72.0",
"port-version": 0
},
"boost-accumulators": {
- "baseline": "1.75.0",
- "port-version": 1
+ "baseline": "1.72.0",
+ "port-version": 0
},
"boost-algorithm": {
- "baseline": "1.75.0",
+ "baseline": "1.72.0",
"port-version": 0
},
"boost-align": {
- "baseline": "1.75.0",
+ "baseline": "1.72.0",
"port-version": 0
},
...
"boost-uninstall: {
"baseline": "1.75.0",
"port-version": 0
},
...
```
Some `boost-` packages are helpers used by vcpkg and are not part of Boost. For example, `"boost-uninstall"` is a vcpkg helper to conveniently uninstall all Boost libraries, but it didn't exist for Boost version `1.72.0`, in this case it is fine to leave it at `1.75.0` to avoid baseline errors (since all versions in `baseline.json` must have existed).
### Step 3: Commit your changes
After saving your modified file, run these commands to commit your changes:
```
git add versions/baseline.json
git commit -m "Baseline Boost 1.72.0"
```
You can set the commit message to whatever you want, just make it useful for you.
### Step 4: Get your baseline commit SHA
Once all your changes are ready, you can get the commit SHA by running:
```
git rev-parse HEAD
```
The output of that command will be the commit SHA you need to put as the `"builtin-baseline"` in your project's manifest file. Copy the 40-hex digits and save them to use later in your manifest file.
### Step 5: (Optional) Go back to the main repository branch
Once your changes have been committed locally, you can refer to the commit SHA regardless of the repository branch you're working on. So, let's go back to the main vcpkg repository branch.
In this example, commit SHA `9b5cf7c3d9376ddf43429671282972ec4f99aa85` is the commit ID with the modified baseline. Even when a different branch (`master` in this case) is checked out, Git is able to find the commit as long as the branch with the modified baseline exists (the `custom-boost-baseline` branch we created in step 1).
We run `vcpkg --feature-flags="manifests,versions" install` in the directory containing our manifest file and the output looks like this:
```
The following packages will be built and installed:
Notice how simple our manifest file has become, instead of having a multitude of `"overrides"` you can pin down all Boost packages just by setting the `"builtin-baseline"` to be your modified baseline commit SHA.