cmake-vcpkg — GitHub Copilot rule: C++ builds and packages
A rule that gives Copilot the context of a C++ project: vcpkg in manifest mode, settings through CMakePresets.json, builds for MSVC, Clang and GCC.
.github/instructions/cmake-vcpkg.instructions.mdWhat cmake-vcpkg does
The rule attaches to *.cmake, CMakeLists.txt, *.cpp, *.h and *.hpp files and changes what Copilot suggests inside them. The key point: the project uses vcpkg in manifest mode, so advice like vcpkg install library will not work — dependencies live in the manifest, not in a hand-run command.
Copilot is told to set cache variables and similar settings through CMakePresets.json rather than scattering them across CMakeLists.txt. When a suggested variable is affected by CMake policies, the rule asks for those policies to be named — otherwise the value may behave differently than expected. The project has to build for MSVC, Clang and GCC, so single-platform suggestions are off the table.
There is a separate clause for OpenCV: file-reading samples must use absolute paths. That means video.open("C:/project/file.mp4"), not video.open("file.mp4") — a relative path breaks as soon as the sample runs from another working directory.
What it helps with
- tell Copilot that vcpkg runs in manifest mode
- get dependency advice without manual
vcpkg install - move build settings into
CMakePresets.json - account for CMake policies when editing variables
- write OpenCV samples that survive a different working directory
Example prompts for the agent
- add a library dependency through the vcpkg manifest
- move these build variables into
CMakePresets.json - check that the OpenCV sample uses an absolute file path
How to install cmake-vcpkg
Manually: put the files in place
.github/instructions/cmake-vcpkg.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.claude/rules/cmake-vcpkg.mdThe paths frontmatter field limits the files: move applyTo from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/cmake-vcpkg.mdcFrontmatter: description, globs, alwaysApply. Move applyTo from the source into globs, or the rule will not attach on its own
Manually: put the files in place
.devin/rules/cmake-vcpkg.mdManually: put the files in place
.clinerules/cmake-vcpkg.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about cmake-vcpkg
How do I install cmake-vcpkg in GitHub Copilot?
Place the file at .github/instructions/cmake-vcpkg.instructions.md in your repository. The rule then applies to the files listed in applyTo.
What does cmake-vcpkg do?
It gives Copilot the context of a C++ project: vcpkg in manifest mode, settings via CMakePresets.json, and builds for MSVC, Clang and GCC. It also asks for CMake policies to be named and for absolute paths in OpenCV samples.
Why does the rule reject vcpkg install suggestions?
The project uses vcpkg in manifest mode, so that command will not behave as expected. Dependencies are declared in the manifest instead.
Source text
cmake-vcpkg.instructions.md · MIT
---
description: 'C++ project configuration and package management'
applyTo: '**/*.cmake, **/CMakeLists.txt, **/*.cpp, **/*.h, **/*.hpp'
---
This project uses vcpkg in manifest mode. Please keep this in mind when giving vcpkg suggestions. Do not provide suggestions like vcpkg install library, as they will not work as expected.
Prefer setting cache variables and other types of things through CMakePresets.json if possible.
Give information about any CMake Policies that might affect CMake variables that are suggested or mentioned.
This project needs to be cross-platform and cross-compiler for MSVC, Clang, and GCC.
When providing OpenCV samples that use the file system to read files, please always use absolute file paths rather than file names, or relative file paths. For example, use `video.open("C:/project/file.mp4")`, not `video.open("file.mp4")`.
© github · MIT · github/awesome-copilot