vcpkg C/C++ Package Manager
repository·master·Indexed 12 days ago
https://github.com/microsoft/vcpkgA cross-platform, open-source C/C++ package manager maintained by Microsoft and the community. It simplifies dependency management for Windows, macOS, and Linux, integrating with build systems like CMake and MSBuild. Supports both Manifest mode for reproducible builds and Classic mode for global package management.
What's inside vcpkg
- vcpkg is a free and open-source C/C++ package manager maintained by Microsoft and the C++ community. It is a cross-platform tool designed for Windows, macOS, and Linux that supports various build and project systems. It is written in C++ and uses CMake for scripting.
How the ANGLE vcpkg port buildsystem works
masterThe ANGLE port uses a buildsystem derived from WebKit's approach to converting ANGLE's buildsystem to CMake. It consists of an augmented version of WebKit'sCMakeLists.txtand customized configuration files located incmake-buildsystem/. These configuration files are adapted for vcpkg and usePlatformLinuxinstead ofPlatformGTK.Understand the Owners DB output file formats
masterBoth
file_script.tsandfile_script_from_cache.tsproduce two specific plain-text database files in the specified--out-dir(defaultscripts/list_files).VCPKGDatabase.txt
A newline-separated list of all files in the packages.
- Format:
<port>:<triplet>:<filepath> - Example:
zlib:x64-windows:/share/zlib/include/zlib.h - Note:
<filepath>always begins with a leading/.
VCPKGHeadersDatabase.txt
A filtered list containing only header files.
- Format:
<port>:<triplet>:<relative/header/path> - Filtering Logic: Only files whose path starts with
/include/are recorded. The/include/prefix is stripped from the resulting path. - Example: An entry for
/include/zlib.hbecomeszlib:x64-windows:zlib.h.
- Format:
Update the ANGLE vcpkg port
masterTo update the ANGLE port to a new version, follow these steps:
- Select a new ANGLE version: Follow the libANGLE guide for matching a branch to the current Chromium Stable.
- Update version metadata: Find the branch (typically
chromium/<version>) and the latest commit. UpdateANGLE_COMMIT,ANGLE_VERSION, andANGLE_SHA512inportfile.cmake. - Sync third-party dependencies: Check the
DEPSfile at the selected ANGLE commit for thethird_party/zlibcommit. UpdateANGLE_THIRDPARTY_ZLIB_COMMITinportfile.cmakeif it has changed. - Build and adjust: Attempt a build. You may need to modify
CMakeLists.txtorPlatform*.cmakefiles. Compare these with the latest files in the WebKit repository to port any necessary updates. You may also need to updateANGLE_WEBKIT_BUILDSYSTEM_COMMITin theportfile.cmake. - Verify headers: Compare ANGLE headers against
opengl-registryto ensure similarity. Note that ANGLE defines some additional entrypoints. Ensureopengl-registryis updated to the latest version before updating ANGLE. - Finalize: Complete the standard maintenance steps defined in the vcpkg Maintainer Guide.
Guidelines for contributing new packages
masterWhen creating a new port file for a package, follow these best practices to ensure maintainability:
- Minimize Patches: Avoid using patches to add features. Patches should only be used as a last resort to ensure compatibility.
- Preserve Default Behavior: If a patch is unavoidable, do not modify the library's default behavior. The goal is for the patch to eventually be merged upstream so it is no longer needed in vcpkg.
- Use vcpkg Helper Functions: Prefer using built-in
vcpkg_xyzfunctions over rawexecute_commandcalls. This makes it easier to maintain the port when new features (like custom compiler flags or generators) are added to vcpkg.
Complete the Contributor License Agreement (CLA)
masterBefore any Pull Request (PR) can be accepted, you must complete the Microsoft Contributor License Agreement (CLA). This agreement grants permission to use your submitted source code under the appropriate license.
You only need to complete this process once. Follow the steps at https://cla.microsoft.com to sign the CLA.
Install flash-runtime-extensions via vcpkg
masterTheflash-runtime-extensionsport provides a CMake-compatible version of theFlashRuntimeExtensionslibrary. You can integrate this library into your C++ projects using vcpkg's CMake integration.Configure guest environment and Xcode for macOS VMs
masterOnce the macOS VM is running, you must configure the
vcpkguser to allow seamless automation. This includes setting up passwordlesssudo, installing Xcode, and preparing the Azure Agent.Steps to configure the guest:
- Passwordless Sudo: Create a sudoers file for the
vcpkguser. - Xcode Installation: Expand the
.xipand moveXcode.appto/Applications. - Azure Agent Setup: Update
setup-box.shwith the correct Azure Agent URI and run the setup scripts (setup-guest.shandsetup-box.sh) usingclt.dmg(renamed fromtools.dmg).
Note: When opening Xcode for the first time, uncheck the "code completion model" and accept the EULA.
# Configure passwordless sudo printf 'vcpkg\tALL=(ALL)\tNOPASSWD:\tALL\n' | sudo tee -a '/etc/sudoers.d/vcpkg' sudo chmod 0440 '/etc/sudoers.d/vcpkg' # Expand and install Xcode sudo mdutil -ad xip --expand Xcode.xip sudo mv Xcode.app /Applications/Xcode.app rm Xcode.xip- Passwordless Sudo: Create a sudoers file for the
Create new vcpkg-eg-mac ARM64 base images
masterUse this checklist to update or create new macOS ARM64 base images for the vcpkg agent pool. This process involves preparing a host machine, minting a new VM using
macosvmwith a macOS.ipswfile, configuring the guest environment (Xcode, sudo permissions, Azure Agent URI), and uploading the resulting archive to blob storage.Prerequisites
macosvmallow-listed by macOS for arm64.- Xcode
.xipand Xcode Command Line Tools installer. - PowerShell 7.x, Azure CLI, and
az loginwith Microsoft credentials.
High-level Workflow
- Prepare Host: Delete an idle agent from the Azure DevOps OSX queue and access the machine via KVM.
- Install
macosvm: Install themacosvmtool to the home directory. - Initialize VM: Create a directory in
~/Parallels/vcpkg-osx-<date>-arm64and usemacosvmto create the disk and restore from a.ipswfile. - Configure Guest: Follow macOS setup prompts (Account:
vcpkg), disable automatic updates, enable Remote Login, and configure passwordlesssudofor thevcpkguser. - Install Tooling: Install Xcode via
.xipexpansion and updatesetup-box.shwith the current Azure Agent URI. - Package & Upload: Archive the VM using
aa archiveand upload the.aarfile to thevcpkgimagemintingstorage account usingazcopy.
# Create the VM directory and run macosvm mkdir -p ~/Parallels/vcpkg-osx-2026-01-12-arm64 cd ~/Parallels/vcpkg-osx-2026-01-12-arm64 ~/macosvm --disk disk.img,size=500g --aux aux.img -c 8 -r 12g --restore ~/UniversalMac_26.4.1_25E253_Restore.ipsw ./vm.json ~/macosvm -g ./vm.jsonUse vcpkg in Classic Mode
masterIn classic mode, you install packages directly through the command line without a project-specific manifest. This is useful for global package management.
vcpkg install fmtPerform Patch Tuesday maintenance tasks
masterDuring each Patch Tuesday cycle, follow these steps to maintain the Windows and macOS images used for validation:
Windows Image Maintenance
- Check Dependencies: Review
depends:vm-updatePull Requests and apply necessary changes. - Monitor Security Alerts: Check Service 360 alerts (e.g., at https://aka.ms/s360) for the service "C++ VCPKG Validation" to identify vulnerable software (often requiring PowerShell updates).
- Update Software: Check for any other software updates required for Windows images and apply edits in
scripts/azure-pipelines/windows. - Update Tools: Check for available updates to
vcpkg-tools.json. - Create Image: Run the image creation script:
windows/create-image.ps1 - Finalize: Submit and merge a PR with your changes, then mark the newly created image as 'latest' in the Azure portal.
macOS Image Maintenance
- Mint Base Box: Mint a new macOS base box by following the instructions in
scripts/azure-pipelines/osx/README.md. - Deploy: Deploy the new base box to all hosts.
windows/create-image.ps1- Check Dependencies: Review
First time machine setup for vcpkg validation
masterTo set up a machine for the first time to perform vcpkg validation tasks, complete the following steps:
- Install Azure PowerShell: Follow the official Microsoft documentation to install the Azure PowerShell module.
- Authenticate with Azure: Run the connection command to authenticate against the specific subscription.
- Install Docker: Ensure Docker is installed on the machine to support containerized workflows.
Connect-AzAccount -Subscription CPP_GITHUB