Project 4: Dependency Management with vcpkg
A simple console application that uses a third-party library, like
{fmt}for string formatting ornlohmann/jsonfor 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 searchandvcpkg install - Integrating with CMake → maps to using
find_packageandtarget_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
- Reproduce the simplest happy-path scenario.
- Build the smallest working version of the core feature.
- Add input validation and error handling.
- Add instrumentation/logging to confirm behavior.
- 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.