Skip to content

build-cpp/vcpkg_template

Repository files navigation

vcpkg_template

This is a template showcasing cmkr together with vcpkg for frictionless cross platform dependency management with CMake.

Building

Use the following commands to build the project:

cmake -B build
cmake --build build

cmake.toml

Under the hood cmkr generates the CMakeLists.txt required to build this project from the cmake.toml file:

[project]
name = "vcpkg_template"

# See https://vcpkg.link for available packages
# Chose a version from https://github.com/microsoft/vcpkg/releases
[vcpkg]
version = "2024.11.16"
packages = [
    "fmt",
    # disable default features (core) and enable DBSTAT virtual table (dbstat)
    "sqlite3[core,dbstat]",
    "mylib",
]
overlay = "vcpkg-overlay"

# Make the packages available to CMake
[find-package.fmt]
[find-package.unofficial-sqlite3]
[find-package.unofficial-mylib]

[target.example]
type = "executable"
sources = ["src/main.cpp"]
link-libraries = [
    "fmt::fmt",
    "unofficial::sqlite3::sqlite3",
    "unofficial::mylib::mylib",
]

Vcpkg overlay

The [vcpkg].overlay key points to a local folder used as an overlay for vcpkg ports and triplets:

vcpkg-overlay
├── mylib              # custom port
│   ├── CMakeLists.txt
│   ├── portfile.cmake
│   ├── usage
│   └── vcpkg.json
└── x64-windows.cmake  # custom triplet

The vcpkg-overlay/mylib overlay port is used to make the example mylib available without having to fork the vcpkg repository or create a custom registry.

The vcpkg-overlay/x64-windows.cmake overlay triplet is used to always build static libraries for Windows (instead of shared libraries, which is normally the default).

About

Simple cmkr template to get you started with vcpkg right away.

Topics

Resources

License

Stars

Watchers

Forks