Overlays#
Overlays enable the vcpkg overlay feature, which allows user to customize the build triplets and ports of vcpkg.
Overlay of a custom triplet#
According to the official documentation, to add a custom triplet, create a new directory and copy the
tripletsdirectory from the vcpkg installation directory to the new directory. Then, create atripletfile in the new directory and modify theCMAKE_SYSTEM_NAMEandVCPKG_TARGET_ARCHITECTUREvariables to match your custom triplet. Finally, add the new directory to theoverlay-tripletslist in thevcpkg.jsonfile.
The scaffold designed for this purpose, we create a new directory cmake/vcpkg/triplets in the root of our scaffold which has been registered as an overaly-triplets in vcpkg.json. Inside this directory, what we need to do is create a new triplet file according to the triplet naming convention CPU-OS/compiler-runtime.cmake(Triplet is a standard term used in cross-compiling as a way to completely capture the target environment in a single, convenient name) for example, x64-linux-dynamic.cmake or arm64-windows-static.cmake. Or we can copy an existing triplet file from the vcpkg root directory and modify it according to our needs.
References:
Overlay of a custom port#
A port based on vcpkg is a set of files that can be used to build a library or an executable.
There are two ways to add a custom port to vcpkg:
Create a vcpkg registry repository and add the port to it. The repository can be added to the
registrieslist in thevcpkg.jsonfile. That’s the way the cmake-registry registry in the scaffold is implemented.Add a port to the
overlay-portsdirectory of the project which can be used to register the port in thevcpkg.jsonfile. Actually, this is doing the same thing as the overlay triplets and the way in which thecmake/vcpkg/portsdirectory in the scaffold also is implemented. See also the vcpkg official documentation on overlay-ports.
References:
Overlay of a custom chianload toolchain#
a toolchain file is selected from
scripts/toolchains/appropriate to the platform by default.
To use a custom chianload toolchain, a directory cmake/vcpkg/scripts/toolchains has been created in the root of the scaffold.
References: