GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - GLaDOS-418/cpp-project-template: A modern C++ Project Template.

BranchesTags
Open more actions menu

Latest commit

 

History

38 Commits
38 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.vscode
.vscode
 
 
app
app
 
 
cmake
cmake
 
 
libs
libs
 
 
.clang-format
.clang-format
 
 
.clang-tidy
.clang-tidy
 
 
.clangd
.clangd
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CMakeLists.txt
CMakeLists.txt
 
 
CMakePresets.json
CMakePresets.json
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
conan.profile
conan.profile
 
 
conanfile.txt
conanfile.txt
 
 

Repository files navigation

Modern C++ Project Template

A basic project template for modern C++. Below are some better resources:

  • filipdutescu/modern-cpp-template
  • cpp-best-practices/cmake_template
  • cpp-best-practices/cpp_starter_project - ARCHIVED

Setup Progress

Use the latest version of everything.

- [x] Compiler                        : clang++
- [x] Build                           : cmake
- [x] Package Management              : conan2.0
- [x] Unit Testing                    : catch2
- [x] Static Code Analysers           : clang-tidy
- [x] Code Formatter                  : clang-format
- [ ] Code Coverage                   : gcov
- [ ] Consolidate Built Artifacts     : cpack
- [x] Sharable Dev Environment        : docker
- [ ] CI workflows                    : github workflows
- [ ] Code documentation              : doxygen
- [ ] Mocking Framework               : gmock
- [ ] Fuzz Testing                    : libfuzzer
- [ ] Ccache Integration              : ccache
- [ ] Header File Manager             : include-what-you-use
- [x] Language Server                 : clangd

Build Instructions

  • create application and test executables
  • use conan 2.0
  • generate a default conan profile. update profile in the build in makefile if not default.
$ make clean     ## remove build dir
$ make deepclean ## remove build dir + remove conan cache
$ make format    ## format code using clag-format
$ make package   ## installs all package dependencies (using conan)
$ make build     ## build project inside build dir ( +package +format)
$ make rebuild   ## equivalent to `clean + build`
$ make test      ## run tests from test folder
$ make testprint ## run only failed tests and ouput on stdout
$ make image     ## build docker image using .devcontainer/Dockerfile for dev
$ make terminal  ## start a terminal and load current project dir as a volume
  • check build in Makefile for step by step build process
  • the cmake built artifacts are in the build folder.
  • build logs are in the logs folder.
  • to clear conan cache, run : $ conan remove -f '*'
  • here's a sample conan profile which can be gerenated using the command
  • conan.profile is used as a custom conan profile.
  • docker image generated from $ make image is cppdev:latest.
  • docker container started from $ make terminal is cppdev_container.
$ conan profile detect ## creates a default conan profile
$ cat ~/.conan2/profiles/default
[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.cppstd=gnu23
compiler.libcxx=libstdc++11
compiler.version=18
os=Linux

New Project

you can add below function to your ~/.bashrc to set up new projects.

  • $ new_cpp_project foobar
  • creates a new project, foobar, with all the contents of basic branch of this repo.
  • provide the name of the new project as argument.
function new_cpp_project {
  if [ ! ${1} ]
  then
    echo "project name not supplied..."
    return
  fi

  git clone --depth 1 --single-branch --branch basic [email protected]:GLaDOS-418/cpp-project-template.git ${1}
  cd ${1}
  /usr/bin/rm -rf .git
  echo "# ${1}" >| README.md
  grep -rl --color=never 'project_name' | xargs sed -i "s/project_name/${1}/g"
  git init
  git add -f .
  git commit -m "created project ${1}."

  echo " ========================   PROJECT ${1} SETUP COMPLETE.  ======================== "
}

Clang-Format

  • the config in the repo is generated using the tool itself:
    • $ clang-format -style=chromium -dump-config > .clang-format.
  • supported styles: google, llvm, gnu, mozilla, chromium, microsoft, webkit.
  • change .clang-format file to customize.

Clang-Tidy

  • TODO: cppcheck can be an addendum.

Clangd

  • modify .clangd file
  • .clang-tidy options are merged with .clangd when IDE suggests.

Guidelines

  • C++ Core Guidelines
  • Google C++ Style Guide
  • LLVM Coding Standards — LLVM 19.0.0git documentation
  • Chromium C++ style guide
  • C++ Coding style — Firefox Source Docs documentation
  • Code Style Guidelines | WebKit
  • GNU Coding Standards
  • Epic C++ Coding Standard For Unreal Engine
  • C++ Coding Standards and Style Guide - NASA Technical Reports Server (NTRS)

About

A modern C++ Project Template.

Resources

Readme
MIT license
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.