Project 4: Dependency Management with vcpkg

A simple console application that uses a third-party library, like {fmt} for string formatting or nlohmann/json for JSON parsing, and manage that dependency entirely through vcpkg and CMake.

Quick Reference

Attribute Value
Primary Language C++
Alternative Languages N/A
Difficulty Level 1: Beginner
Time Estimate Weekend
Knowledge Area Build Systems / Dependency Management
Tooling CMake, vcpkg
Prerequisites Project 1 (CMake setup).

What You Will Build

A simple console application that uses a third-party library, like {fmt} for string formatting or nlohmann/json for JSON parsing, and manage that dependency entirely through vcpkg and CMake.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Installing and integrating vcpkg → maps to running the bootstrap script and using the CMake toolchain file
  • Finding and installing a package → maps to using vcpkg search and vcpkg install
  • Integrating with CMake → maps to using find_package and target_link_libraries
  • Understanding manifest mode vs. classic mode → maps to declarative dependencies (vcpkg.json) vs. imperative installation

Key Concepts

  • vcpkg Integration: vcpkg docs - “CMake Integration”
  • CMake find_package: CMake documentation
  • vcpkg Manifests: vcpkg docs - “Manifest Mode”

Real-World Outcome

# In your project directory
> vcpkg new --application
> vcpkg add port fmt

# Edit your main.cpp to use fmt
# #include <fmt/core.h>
# fmt::print("The answer is {}.", 42);

# Configure with CMake, pointing to the vcpkg toolchain
> cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=[path-to-vcpkg]/scripts/buildsystems/vcpkg.cmake

# Build
> cmake --build build

# Run
> ./build/Debug/my_app.exe
The answer is 42.

Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: LEARN_WINDOWS_SYSTEMS_PROGRAMMING_CPP.md
  • N/A, rely on official documentation.