conan-vcpkg
Use when adding C/C++ dependencies with Conan or vcpkg, managing binary compatibility, integrating with CMake via conanfile.txt or vcpkg.json, or choosing between Conan and vcpkg.
Install
npx skills add https://github.com/OutlineDriven/outline-driven-development/tree/main/.devin/skills/conan-vcpkg
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install outlinedriven-outline-driven-development@llmmart
git clone https://github.com/OutlineDriven/outline-driven-development.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole outlinedriven/outline-driven-development collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Conan and vcpkg
C/C++ dependency management with Conan and vcpkg. Grounded against Conan 2.32.0 and vcpkg 2026.07.29.
Contract
| Field | Bound contract |
|---|---|
| Trigger | The task adds a third-party C/C++ library, writes conanfile.txt/conanfile.py or vcpkg.json, integrates a package manager with CMake, manages binary compatibility, or picks between Conan and vcpkg. |
| Authority | Reversible local: writes only conanfile.*, vcpkg.json, profiles, triplets, overlay ports, and the local package caches; rollback is version control plus clearing the cache. No remote mutation. |
| Side effect | Package installs download sources or binaries into the local Conan or vcpkg cache; conan upload pushes to a remote and requires an explicit user request. |
| Done | The declared dependencies resolve and the project configures and builds against them, or the failing command is reported. |
Inputs
- Dependency list (required): library names; versions come from ConanCenter or the vcpkg registry.
- Build system (required): CMake integration is assumed below.
- Platform constraints (optional): cross-compilation target, static vs shared linkage, MSVC vs GCC/Clang.
- Private remote (optional): an Artifactory or Conan remote URL supplied by the user.
Procedure
- Pick the package manager. Done when: one tool is chosen with a stated reason.
| Situation | Pick |
|---|---|
| MSVC-first Windows team | vcpkg: tighter MSVC and Visual Studio integration |
| Prebuilt binaries in CI, no source builds | Conan: binary package cache and package IDs |
| Cross-compilation profiles | Conan: host/build profile split |
| Exact version pinning per package | Conan: explicit version references |
| Fast setup for a small project | vcpkg manifest mode |
| Open-source project with broad audience | vcpkg: lower barrier for contributors |
- Set up vcpkg in manifest mode. Done when:
vcpkg.jsonexists and CMake configures with the vcpkg toolchain file.
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh # Linux/macOS; .bat on Windows
{
"name": "myapp",
"version": "1.0.0",
"dependencies": [
"zlib",
"curl",
{ "name": "openssl", "version>=": "3.0.0" },
{ "name": "boost-filesystem", "platform": "!windows" },
{ "name": "fmt", "features": ["core"] }
],
"builtin-baseline": "<vcpkg commit sha>"
}
Pin builtin-baseline to a vcpkg commit so every build resolves the same package set; get it with git -C /path/to/vcpkg rev-parse HEAD and refresh it with vcpkg x-update-baseline.
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build
find_package(ZLIB REQUIRED)
find_package(CURL REQUIRED)
find_package(fmt REQUIRED)
target_link_libraries(myapp PRIVATE ZLIB::ZLIB CURL::libcurl fmt::fmt)
- Set up Conan 2 with the CMake generators. Done when:
conan installproducesconan_toolchain.cmakeand the project configures against it.
pip install conan
conan profile detect # writes a default profile for the local compiler
conan profile show # inspect it
# conanfile.txt; versions are examples, check ConanCenter for current releases
[requires]
zlib/1.3
fmt/10.2.1
openssl/3.2.0
[generators]
CMakeDeps
CMakeToolchain
[options]
openssl/*:shared=False
conan install . --output-folder=build --build=missing
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release
cmake --build build
find_package(ZLIB REQUIRED)
find_package(fmt REQUIRED)
find_package(OpenSSL REQUIRED)
target_link_libraries(myapp PRIVATE ZLIB::ZLIB fmt::fmt OpenSSL::SSL OpenSSL::Crypto)
- Cross-compile with Conan profiles. The host profile describes the target; the build profile describes the machine running the build. Done when:
conan install --profile:host=<target>resolves packages for the target.
# ~/.conan2/profiles/linux-arm64
[settings]
os=Linux
arch=armv8
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Release
[buildenv]
CC=aarch64-linux-gnu-gcc
CXX=aarch64-linux-gnu-g++
conan install . \
--profile:build=default \
--profile:host=linux-arm64 \
--output-folder=build-arm \
--build=missing
- Use
conanfile.pywhen logic is needed: conditional requirements, custom generate or build steps. Done when: the recipe'srequirements,generate, andbuildmethods cover the project's conditions.
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
class MyAppConan(ConanFile):
name = "myapp"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
def requirements(self):
self.requires("zlib/1.3")
self.requires("fmt/10.2.1")
if self.settings.os == "Linux":
self.requires("openssl/3.2.0")
def generate(self):
CMakeToolchain(self).generate()
CMakeDeps(self).generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
- Map common libraries between the two registries. Done when: each needed library has a name in the chosen registry.
| Library | vcpkg name | Conan name |
|---|---|---|
| zlib | zlib |
zlib |
| OpenSSL | openssl |
openssl |
| libcurl | curl |
libcurl |
fmt |
fmt |
|
| spdlog | spdlog |
spdlog |
| Boost | boost |
boost |
| nlohmann-json | nlohmann-json |
nlohmann_json |
| GoogleTest | gtest |
gtest |
| Google Benchmark | benchmark |
benchmark |
| SQLite | sqlite3 |
sqlite3 |
| protobuf | protobuf |
protobuf |
For baseline pinning, triplets, overlay ports, binary caches, and lockfiles see references/package-manager-patterns.md.
Failure and recovery
- Package not found: check the name against the registry (
conan searchorvcpkg search); names differ between the two. conan install --build=missingbuilds from source and fails: read the package build log; a missing system tool or an unsupported setting (compiler.libcxx,arch) is the usual cause.- Binary incompatibility (link errors, ABI mismatch): rebuild the package with the project's
build_typeand compiler settings; Conan package IDs encode these. - vcpkg resolves wrong versions: pin
builtin-baseline; without it the registry floats. - CMake cannot find Conan-generated files: confirm
-DCMAKE_TOOLCHAIN_FILEpoints at theconan_toolchain.cmakeunder the--output-folderused at install time. conan uploadis a remote write: run it only when the user explicitly asks to publish.
Output
A working dependency declaration (conanfile.txt/conanfile.py or vcpkg.json), the matching CMake integration, and a verified configure and build. For selection tasks, the decision table row that applies with its reason.
Files (outline-driven-development)
-
agents
-
openai.yaml 287 B
interface: display_name: "Conan Vcpkg" short_description: "Use when adding C/C++ dependencies with Conan or vcpkg, managing binary compatibility, integrating with CMake via conanfile.txt or vcpkg.json, or choosing between Conan and vcpkg." policy: allow_implicit_invocation: false
-
-
references
-
package-manager-patterns.md 4.1 KB
# Conan and vcpkg patterns reference Grounded against Conan 2.32.0 and vcpkg 2026.07.29. ## vcpkg baseline pinning `builtin-baseline` pins every package to the versions at one vcpkg commit: ```json { "name": "myapp", "version": "1.0.0", "builtin-baseline": "<vcpkg commit sha>", "dependencies": [ "zlib", "fmt", { "name": "openssl", "version>=": "3.0.0" } ] } ``` ```bash git -C /path/to/vcpkg rev-parse HEAD # current baseline vcpkg x-update-baseline # refresh the baseline field ``` ## vcpkg features and triplets ```json { "dependencies": [ { "name": "boost", "features": ["filesystem", "program_options"] }, { "name": "openssl", "default-features": false, "features": ["ssl", "crypto"] } ] } ``` ```cmake # triplets/x64-linux-release.cmake set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE static) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) set(VCPKG_BUILD_TYPE release) # build release only, skip debug ``` ```bash cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_TARGET_TRIPLET=x64-linux-release \ -DVCPKG_OVERLAY_TRIPLETS=triplets/ ``` ## vcpkg in CI Bootstrap vcpkg in the workflow, then configure with its toolchain file. Pin the vcpkg commit in `builtin-baseline` so CI and local builds resolve the same package set. ```bash git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT" "$VCPKG_ROOT"/bootstrap-vcpkg.sh -disableMetrics cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \ -DCMAKE_BUILD_TYPE=Release cmake --build build ``` ## vcpkg overlay ports Overlay ports add packages the registry does not carry: ```text my-project/ ├── vcpkg.json └── ports/ └── mylib/ ├── vcpkg.json ├── portfile.cmake └── usage ``` ```cmake # portfile.cmake vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO myorg/mylib REF v1.2.3 SHA512 <sha512 of the archive> HEAD_REF main ) vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}") vcpkg_cmake_install() vcpkg_cmake_config_fixup() # provided by the vcpkg-cmake-config helper port file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") ``` ```bash cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_OVERLAY_PORTS=ports/ ``` ## Conan remotes and binary cache ```bash conan remote list conan remote add mycompany https://artifactory.example.com/artifactory/api/conan/conan-local # Upload is a remote write; run it only on explicit request conan upload "*" --remote mycompany --confirm # Consume prebuilt binaries without --build=missing conan install . --remote mycompany ``` ## Conan lockfiles ```bash conan lock create . --build=missing # write conan.lock conan install . --lockfile=conan.lock # reproduce from the lockfile conan lock update conan.lock # refresh after a dependency change ``` `--lockfile-out=<path>` on `conan install` writes the resolved lockfile to a separate file; `--lockfile-partial` tolerates deps missing from the lock. ## Mixing Conan and non-Conan dependencies ```cmake # Conan-managed find_package(fmt REQUIRED) find_package(OpenSSL REQUIRED) # System-provided find_package(Threads REQUIRED) find_package(X11) # Vendored in-tree add_subdirectory(third_party/myhdr) ``` ## Packaging your own library with Conan ```python from conan import ConanFile from conan.tools.cmake import CMake, cmake_layout class MyLibConan(ConanFile): name = "mylib" version = "1.0.0" settings = "os", "compiler", "build_type", "arch" exports_sources = "src/*", "include/*", "CMakeLists.txt" def layout(self): cmake_layout(self) def build(self): cmake = CMake(self) cmake.configure() cmake.build() def package(self): CMake(self).install() def package_info(self): self.cpp_info.libs = ["mylib"] ``` ```bash conan create . --build=missing # builds and exports to the local cache # consumers then require: mylib/1.0.0 ```
-
-
SKILL.md 7.1 KB
--- name: conan-vcpkg description: 'Use when adding C/C++ dependencies with Conan or vcpkg, managing binary compatibility, integrating with CMake via conanfile.txt or vcpkg.json, or choosing between Conan and vcpkg.' disable-model-invocation: true --- # Conan and vcpkg C/C++ dependency management with Conan and vcpkg. Grounded against Conan 2.32.0 and vcpkg 2026.07.29. ## Contract | Field | Bound contract | |---|---| | Trigger | The task adds a third-party C/C++ library, writes `conanfile.txt`/`conanfile.py` or `vcpkg.json`, integrates a package manager with CMake, manages binary compatibility, or picks between Conan and vcpkg. | | Authority | Reversible local: writes only `conanfile.*`, `vcpkg.json`, profiles, triplets, overlay ports, and the local package caches; rollback is version control plus clearing the cache. No remote mutation. | | Side effect | Package installs download sources or binaries into the local Conan or vcpkg cache; `conan upload` pushes to a remote and requires an explicit user request. | | Done | The declared dependencies resolve and the project configures and builds against them, or the failing command is reported. | ## Inputs - Dependency list (required): library names; versions come from ConanCenter or the vcpkg registry. - Build system (required): CMake integration is assumed below. - Platform constraints (optional): cross-compilation target, static vs shared linkage, MSVC vs GCC/Clang. - Private remote (optional): an Artifactory or Conan remote URL supplied by the user. ## Procedure 1. Pick the package manager. Done when: one tool is chosen with a stated reason. | Situation | Pick | |---|---| | MSVC-first Windows team | vcpkg: tighter MSVC and Visual Studio integration | | Prebuilt binaries in CI, no source builds | Conan: binary package cache and package IDs | | Cross-compilation profiles | Conan: host/build profile split | | Exact version pinning per package | Conan: explicit version references | | Fast setup for a small project | vcpkg manifest mode | | Open-source project with broad audience | vcpkg: lower barrier for contributors | 2. Set up vcpkg in manifest mode. Done when: `vcpkg.json` exists and CMake configures with the vcpkg toolchain file. ```bash git clone https://github.com/microsoft/vcpkg.git ./vcpkg/bootstrap-vcpkg.sh # Linux/macOS; .bat on Windows ``` ```json { "name": "myapp", "version": "1.0.0", "dependencies": [ "zlib", "curl", { "name": "openssl", "version>=": "3.0.0" }, { "name": "boost-filesystem", "platform": "!windows" }, { "name": "fmt", "features": ["core"] } ], "builtin-baseline": "<vcpkg commit sha>" } ``` Pin `builtin-baseline` to a vcpkg commit so every build resolves the same package set; get it with `git -C /path/to/vcpkg rev-parse HEAD` and refresh it with `vcpkg x-update-baseline`. ```bash cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake cmake --build build ``` ```cmake find_package(ZLIB REQUIRED) find_package(CURL REQUIRED) find_package(fmt REQUIRED) target_link_libraries(myapp PRIVATE ZLIB::ZLIB CURL::libcurl fmt::fmt) ``` 3. Set up Conan 2 with the CMake generators. Done when: `conan install` produces `conan_toolchain.cmake` and the project configures against it. ```bash pip install conan conan profile detect # writes a default profile for the local compiler conan profile show # inspect it ``` ```ini # conanfile.txt; versions are examples, check ConanCenter for current releases [requires] zlib/1.3 fmt/10.2.1 openssl/3.2.0 [generators] CMakeDeps CMakeToolchain [options] openssl/*:shared=False ``` ```bash conan install . --output-folder=build --build=missing cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \ -DCMAKE_BUILD_TYPE=Release cmake --build build ``` ```cmake find_package(ZLIB REQUIRED) find_package(fmt REQUIRED) find_package(OpenSSL REQUIRED) target_link_libraries(myapp PRIVATE ZLIB::ZLIB fmt::fmt OpenSSL::SSL OpenSSL::Crypto) ``` 4. Cross-compile with Conan profiles. The host profile describes the target; the build profile describes the machine running the build. Done when: `conan install --profile:host=<target>` resolves packages for the target. ```ini # ~/.conan2/profiles/linux-arm64 [settings] os=Linux arch=armv8 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 build_type=Release [buildenv] CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ``` ```bash conan install . \ --profile:build=default \ --profile:host=linux-arm64 \ --output-folder=build-arm \ --build=missing ``` 5. Use `conanfile.py` when logic is needed: conditional requirements, custom generate or build steps. Done when: the recipe's `requirements`, `generate`, and `build` methods cover the project's conditions. ```python from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake class MyAppConan(ConanFile): name = "myapp" version = "1.0" settings = "os", "compiler", "build_type", "arch" def requirements(self): self.requires("zlib/1.3") self.requires("fmt/10.2.1") if self.settings.os == "Linux": self.requires("openssl/3.2.0") def generate(self): CMakeToolchain(self).generate() CMakeDeps(self).generate() def build(self): cmake = CMake(self) cmake.configure() cmake.build() ``` 6. Map common libraries between the two registries. Done when: each needed library has a name in the chosen registry. | Library | vcpkg name | Conan name | |---|---|---| | zlib | `zlib` | `zlib` | | OpenSSL | `openssl` | `openssl` | | libcurl | `curl` | `libcurl` | | {fmt} | `fmt` | `fmt` | | spdlog | `spdlog` | `spdlog` | | Boost | `boost` | `boost` | | nlohmann-json | `nlohmann-json` | `nlohmann_json` | | GoogleTest | `gtest` | `gtest` | | Google Benchmark | `benchmark` | `benchmark` | | SQLite | `sqlite3` | `sqlite3` | | protobuf | `protobuf` | `protobuf` | For baseline pinning, triplets, overlay ports, binary caches, and lockfiles see `references/package-manager-patterns.md`. ## Failure and recovery - Package not found: check the name against the registry (`conan search` or `vcpkg search`); names differ between the two. - `conan install --build=missing` builds from source and fails: read the package build log; a missing system tool or an unsupported setting (`compiler.libcxx`, `arch`) is the usual cause. - Binary incompatibility (link errors, ABI mismatch): rebuild the package with the project's `build_type` and compiler settings; Conan package IDs encode these. - vcpkg resolves wrong versions: pin `builtin-baseline`; without it the registry floats. - CMake cannot find Conan-generated files: confirm `-DCMAKE_TOOLCHAIN_FILE` points at the `conan_toolchain.cmake` under the `--output-folder` used at install time. - `conan upload` is a remote write: run it only when the user explicitly asks to publish. ## Output A working dependency declaration (`conanfile.txt`/`conanfile.py` or `vcpkg.json`), the matching CMake integration, and a verified configure and build. For selection tasks, the decision table row that applies with its reason.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.