vcpkg
swaggercpp ships in the official microsoft/vcpkg registry. Consumers need a working vcpkg installation and a CMake toolchain file wired in.
INFO
vcpkg.io's package browser may take 1–2 weeks to index freshly merged ports. The GitHub path is always the authoritative source.
One-time setup
git clone https://github.com/microsoft/vcpkg C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
setx VCPKG_ROOT C:\vcpkggit clone https://github.com/microsoft/vcpkg ~/vcpkg
~/vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=~/vcpkgAdd to CMakePresets.json (or -DCMAKE_TOOLCHAIN_FILE=...):
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}Manifest mode (recommended)
Put a vcpkg.json next to CMakeLists.txt:
{
"name": "my-app",
"version": "0.1.0",
"dependencies": [ "swaggercpp" ],
"builtin-baseline": "<sha-from-vcpkg>"
}Get a baseline SHA that contains swaggercpp:
git -C $env:VCPKG_ROOT rev-parse HEADOn first cmake --configure, vcpkg installs swaggercpp and its transitive deps into out/build/<preset>/vcpkg_installed/<triplet>/.
Classic mode
vcpkg install swaggercppInstalls into $VCPKG_ROOT/installed/<triplet>/. Works for projects without a vcpkg.json.
Do not mix modes
If a vcpkg.json exists in your project, manifest mode is active and the classic install is ignored. You must declare swaggercpp in dependencies or find_package will fail silently.
Consuming in CMake
find_package(swaggercpp CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE swaggercpp::swaggercpp)
target_compile_features(my_app PRIVATE cxx_std_23)Troubleshooting
error: swaggercpp does not exist
Your local vcpkg clone is missing the port files. Check git status inside $VCPKG_ROOT and restore any deleted files:
git -C $env:VCPKG_ROOT restore ports/swaggercpp/Then git pull to make sure you're on a commit that contains the port.
Could not find package configuration file
Your project has vcpkg.json but does not declare swaggercpp. Add it to dependencies and reconfigure.
Version 0.1.0 keeps installing
You have a stale classic install cached. Remove it and reinstall:
vcpkg remove swaggercpp
vcpkg install swaggercppOverlay ports (for contributors)
If you want to test local changes to packaging/vcpkg/ports/swaggercpp before opening a PR to upstream vcpkg:
vcpkg install swaggercpp --overlay-ports=packaging\vcpkg\ports --classic