mcpField
C
conan-vcpkg

conan-vcpkg

github.com/mohitmishra786開発269623 回インストール18 週間前に更新
リポジトリ

conan-vcpkg について

Conan と vcpkg による C/C++ の依存関係管理をエージェント向けに案内するスキルです。CMake 連携、バイナリ互換性、クロスコンパイル、パッケージマネージャーの選択を扱います。

主な機能

  1. 01Conan と vcpkg の用途比較
  2. 02vcpkg マニフェストと依存関係の設定
  3. 03Conan の設定と依存関係のインストール
  4. 04Conan profiles によるクロスコンパイル
  5. 05パッケージビルドと依存関係の問題解決

活用シーン

  1. 01CMake プロジェクトに C/C++ ライブラリを追加
  2. 02チームに合うパッケージマネージャーの選択
  3. 03Conan のクロスコンパイル先の設定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill conan-vcpkg

インストール後、Claude Code で/conan-vcpkgを入力して読み込まれたか確認します。

同梱ファイルreferences/package-manager-patterns.md

詳細

Conan と vcpkg

目的

Conan と vcpkg を使用した C/C++ の依存関係管理について、エージェントをガイドします。依存関係の宣言、CMake との統合、バイナリ互換性の管理、プロジェクトに適したツールの選択を扱います。

トリガー

  • 「Conan で C++ ライブラリの依存関係を追加するにはどうすればよいですか?」
  • 「vcpkg を CMake と一緒に使うにはどうすればよいですか?」
  • 「Conan と vcpkg の違いは何ですか?」
  • 「パッケージマネージャーで zlib/openssl/fmt を追加するにはどうすればよいですか?」
  • 「vcpkg.json マニフェストを作成するにはどうすればよいですか?」
  • 「Conan パッケージのビルドに失敗します。デバッグするにはどうすればよいですか?」

ワークフロー

1. Conan と vcpkg の選択
Which package manager?
├── Team uses MSVC on Windows primarily → vcpkg (better MSVC integration)
├── Need binary packages (no source builds in CI) → Conan (binary cache)
├── Need cross-compilation support → Conan (profiles) or Zig-based builds
├── Need a specific version of a package → Conan (flexible versioning)
├── Quick project setup, just need it to work → vcpkg (simpler)
└── Open-source project, broad audience → vcpkg (GitHub-integrated)
2. vcpkg のセットアップ
# Clone vcpkg
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh    # Linux/macOS
./vcpkg/bootstrap-vcpkg.bat   # Windows

# Install packages (classic mode)
./vcpkg/vcpkg install zlib curl openssl

# Integrate with CMake
cmake -S . -B build \
    -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
3. vcpkg マニフェストモード(推奨)
// vcpkg.json — place at project root
{
    "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": "abc123..."
}
# CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(myapp)

find_package(ZLIB REQUIRED)
find_package(CURL REQUIRED)
find_package(fmt REQUIRED)

add_executable(myapp src/main.cpp)
target_link_libraries(myapp PRIVATE ZLIB::ZLIB CURL::libcurl fmt::fmt)
# Build — vcpkg automatically installs dependencies
cmake -S . -B build \
    -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build
4. Conan のセットアップ
# Install Conan
pip install conan

# Set up default profile (detects compiler, OS)
conan profile detect

# Check your profile
conan profile show
5. CMake と Conan の連携(Conan 2.x)
# conanfile.txt
[requires]
zlib/1.3
fmt/10.2.1
openssl/3.2.0

[generators]
CMakeDeps
CMakeToolchain

[options]
openssl/*:shared=False
# Install dependencies
conan install . --output-folder=build --build=missing

# Configure and build
cmake -S . -B build \
    -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \
    -DCMAKE_BUILD_TYPE=Release
cmake --build build
# CMakeLists.txt
find_package(ZLIB REQUIRED)
find_package(fmt REQUIRED)
find_package(OpenSSL REQUIRED)

add_executable(myapp src/main.cpp)
target_link_libraries(myapp PRIVATE
    ZLIB::ZLIB
    fmt::fmt
    OpenSSL::SSL OpenSSL::Crypto
)
6. クロスコンパイル用の Conan プロファイル
# ~/.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++

[tool_requires]
# Tools that run on build machine (x86)
# Cross-compile
conan install . \
    --profile:build=default \
    --profile:host=linux-arm64 \
    --output-folder=build-arm \
    --build=missing
7. conanfile.py(応用)
# conanfile.py
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):
        tc = CMakeToolchain(self)
        tc.generate()
        deps = CMakeDeps(self)
        deps.generate()

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()
8. よく使われる依存関係の検索
ライブラリvcpkg 名Conan 名
zlibzlibzlib/1.3
OpenSSLopensslopenssl/3.2.0
libcurlcurllibcurl/8.4.0
{fmt}fmtfmt/10.2.1
spdlogspdlogspdlog/1.12.0
Boostboostboost/1.83.0
nlohmann-jsonnlohmann-jsonnlohmann_json/3.11.3
googletestgtestgtest/1.14.0
Google Benchmarkbenchmarkbenchmark/1.8.3
SQLitesqlite3sqlite3/3.44.0
protobufprotobufprotobuf/4.25.1

vcpkg のベースライン固定と Conan のバイナリキャッシュのセットアップについては、references/package-manager-patterns.md を参照してください。

関連スキル

  • Conan と vcpkg の両方を CMake と統合するには、skills/build-systems/cmake を使用してください
  • Conan プロファイルを使ったクロスコンパイルには、skills/compilers/cross-gcc を使用してください
  • パッケージ管理されたプロジェクトのバックエンドとして、skills/build-systems/ninja を使用してください

コメント