Using a specific version of libraries with VCPKG
As today is not possible to control what version of a library is used in vcpkg. Either you get the latest version of all the libs (when in HEAD) or all the libraries at a particular commit. Having lib X at version vX and lib Y at version vY is only possible if both exists in the same commit.
The community has open different issues. 2823 is a good summary of the situation (with some possible, not working, solutions).
I did a weekend project to try to code a simple solution to deal with this issue. The basic idea is:
1) The user creates a config file (as conanfile.txt, or npm’s package.json) with the list of library and required versions
2) We look at the complete commit history (master branch) of vcpkg repository looking for each library (and all the dependencies for that version) and extract the port folder
3) We create a new vcpkg installation with port folders only for the required libraries at specified versions
4) Execute vcpkg to compile the ports.
The first step was to extract the information into a sqlite database to know in which commit which version of any library appears, including any dependency. The second step was to extract the port folders (moving the commit history and doing a copy).
The code for this solution can be found in this repository.
The solution is far from perfect:
1) My native language is C++ and is coded in Python so go figure!
2) Still no implementation for the configuration file, now is only possible install one library (including all the dependencies)
Implementing the configuration file feature will allow me to extract all the dependencies as a whole, detecting possible incompatibilities (or, at least, informing that a library is uses with different versions and, in this case, use the latest one).
One possible problem is the compatibility of these ports (at and older commit) with vcpkg itself (at a newer commit).