Vcpkg: introducing installation options with Feature Packages
We are happy to announce a new feature for vcpkg in version 0.0.103: Feature Packages.
Vcpkg is a package manager to help acquiring and building open source libraries on Windows; vcpkg currently offers over 600 C++ libraries available for VS2017 and VS2015.
With Feature Packages you have more control over how you build a library as you can specify different options (features). Lots of open source libraries offer different options and features to select at build time. For example, you may want to build OpenCV with CUDA to utilize the GPU or build HDF5 with MSMPI to enable parallel execution. Previously you needed to edit the port file to build with a given set of options. With features packages, these options can be easily specified at installation time.
How to use feature packages
We support optional packages via this syntax: vcpkg install library[feature]
vcpkg install hdf5 // install without parallel support>vcpkg install hdf5[parallel] // install with parallel support
hdf5 now exposes options, so the search command will display more information:
> vcpkg search hdf5hdf5 1.10.1-1 HDF5 is a data model, library, …hdf5[parallel] parallel support for HDF5
Now hdf5 has been installed with the parallel option activated, so the list command will display more information as well:
>vcpkg list hdf5hdf5:x86-windows 1.10.1-1 HDF5 is a data model, …hdf5[parallel]:x86-windows with parallel support for HDF5
Note that each feature package will be listed on a separate line.
Behind the scene
All the features packages for a given library are listed in the CONTROL file.
This file also lists the dependencies for each feature package.
Source: hdf5Version: 1.10.1-1Description: HDF5 is a data model, library, and file format for …Build-Depends: zlib, szip
Feature: parallelDescription: parallel support for HDF5Build-Depends: msmpiA library can support any number of features.
Having feature packages enabled means more subtleties when you remove or update a package. We worked hard to find the right algorithm to addresses collection of edge cases. For example, installing a feature may imply installing dependencies or rebuild in a certain way these dependencies.
> vcpkg install hdf5[parallel]The following packages will be built and installed:hdf5[core,parallel]:x86-windows* msmpi[core]:x86-windows* szip[core]:x86-windowsAdditional packages (*) will be modified to complete this operation.
Vcpkg maintainers, you can now add options to your port file
With feature packages, you have now the ability to define different options when creating a port file. It is now the right time to update your port file and enable options for your libraries.
In order to update your port file, you can react to a feature using the CMake directive
"if(featurename IN_LIST FEATURES)"Here are some resources:
We have updated our documentation about feature package
Thanks to Daniel Shaw for his effort and dedication to implement this feature with us.
As always, your feedback and comments really matter to us, open an issue on GitHub or reach out to us at email@example.com for any comments and suggestions.