Skip to content

marcuwynu23/cpp-cli-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ CLI Project Template

A project template for cross-platform console/CLI applications in C++ using CLI11 for command-line parsing and vcpkg for dependencies.


Features

  • CLI11 — command-line parsing: options, flags, --help, --version, validation
  • vcpkg — manifest-mode dependencies; no global install required
  • CMake — one preset (default); build Debug or Release from the same tree
  • fmt — formatted output (included)

Prerequisites

  • C++17-capable compiler (e.g. MSVC 2019+, GCC 9+, Clang 10+)
  • CMake 3.10 or newer
  • vcpkginstall and set VCPKG_ROOT to your vcpkg directory

Quick start

1. Configure (uses VCPKG_ROOT for the vcpkg toolchain):

cmake --preset default

2. Build (choose Debug or Release):

# Debug
cmake --build build --config Debug

# Release
cmake --build build --config Release

3. Run

  • Windows: .\build\Release\app.exe or .\build\Debug\app.exe
  • Linux/macOS: ./build/app (path may include Release or Debug depending on generator)

Example:

.\build\Release\app.exe --help
.\build\Release\app.exe --name "User" --verbose
.\build\Release\app.exe --version

Project structure

├── CMakeLists.txt      # Build definition, vcpkg toolchain, CLI11 + fmt
├── CMakePresets.json   # Configure preset (default → build/)
├── vcpkg.json          # Dependencies: cli11, fmt
├── vcpkg-configuration.json
├── README.md
└── src/
    └── main.cpp        # Entry point (CLI11 app)

Included CLI example

The sample app in src/main.cpp uses CLI11 and supports:

  • -n,--name — name to greet (default: World)
  • -v,--verbose — verbose output
  • -V,--version — show version
  • -h,--help — show help (auto-generated by CLI11)

Using this as a template

  1. Clone or copy this repository.
  2. Add options/flags in main.cpp with app.add_option(), app.add_flag(), or subcommands with app.add_subcommand(). See CLI11 documentation.
  3. Add dependencies in vcpkg.json and CMakeLists.txt as needed.
  4. Add source files under src/; they are picked up automatically via file(GLOB ...).

Build reference

Goal Command
Configure cmake --preset default
Build Debug cmake --build build --config Debug
Build Release cmake --build build --config Release
Clean Delete the build/ directory and run configure again.

Related


License

Use this template for any purpose. CLI11 is BSD-3-Clause; fmt and other vcpkg ports have their own licenses.

About

A project template for building cross-platform console/cli applications in C++ using CLI11, and vcpkg for dependency management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages