Skip to main content
rule official · GitHub

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.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/instructions/cmake-vcpkg.instructions.md
Open on GitHub

What 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.md

The applyTo field sets which files it applies to

Step 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

Similar IDE rules

All IDE rules for Programming languages →

From the same set732

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor