Skip to content

kelbon/cpp-project-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

С++ project templates

All templates use: cmake, ninja and CPM for dependency management. Also each template includes:

  • clang-format
  • github CI workflow with gcc and clang, sanitizers and cross platform ccache
  • C++20 coroutines library in dependencies (generator, task etc)
  • cmake/deps.cmake file, where you can add your dependencies, e.g. if you need CLI parser and you want to add https://github.com/kelbon/clinok as dependency:
CPMAddPackage(
  NAME CLINOK
  GITHUB_REPOSITORY kelbon/clinok
  GIT_TAG v2.0.1
)

Default C++ standard - C++20

Also best usage will be with vscode + clangd. Each target in cmake (created by template or yourself) will be automatically added into launch.json file for running/debugging.

compile-commands.json for clangd automatically added into project directory after each configuration, so clangd will work with last-configured preset (debug/release/reldbg)

Usage after setupping project:

# For starting git project use
git init
# For configuring
cmake . --preset=debug  # (or release/reldbg)
# For building
ninja -C build # (or build_release / build_reldbg depending on what you want to build)
# For running tests:
ctest --test-dir build # (or build_release / build_reldbg depending on what you want to test)

templates list

benchmark template

link: https://github.com/kelbon/template_benchmark

Usage:

# 1. clone repo
git clone https://github.com/kelbon/template_benchmark
# 2. setup project
cd template_benchmark
cmake -Dproject_name=<your-project-name> -P setup.cmake

Description:

includes google benchmark as dependency and ready-to-use benchmark.cpp.

Note: after configratuion + build you can just F5 in vscode, launch.json file already configured:

image

library template

link: https://github.com/kelbon/template_library

Usage:

# 1. clone repo
git clone https://github.com/kelbon/template_library
# 2. setup project
cd template_library
cmake -Dproject_name=<your-library-name> -P setup.cmake

Description:

includes in /include/

sources in /src. For adding your new .cpp files add them into CMakeLists.txt, in add_library command (GLOB not used, it bad practice for libraries)

tests in /test, each file matching test_*.cpp considered as test and added into ctest run

Creates lib target

CI already has targets cache and sanitizers (ubsan / asan)


app template

link: https://github.com/kelbon/template_app

Usage:

# 1. clone repo
git clone https://github.com/kelbon/template_app
# 2. setup project
cd template_app
cmake -Dproject_name=<your-app-name> -P setup.cmake

Description:

directories, tests adding - same as for library template.

Additionaly provides CLI interface library, main.cpp and program_options.def for describing the program's CLI interface


HTTP service template

Includes HTTP/2 (server/client), SSL, streaming json parser / serializer, code generator API -> C++ code

not yet done, code generator in progress

About

templates for C++ projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published