Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Zhuagenborn/Cpp-Project-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

C++ Project Template

C++ PowerShell CMake Make Docker GitHub Actions Linux

Introduction

A C++ project template on Ubuntu built with:

Building with CMake

Prerequisites

  • Install GoogleTest.
  • Install CMake.

Building

Go to the project folder and run:

mkdir -p build
cd build
cmake ..
cmake --build .

Running Tests

Go to the build folder and run:

ctest -VV

Running the Main Program

Go to the build/bin folder and run:

./cpp-sample

Building with Docker

Prerequisites

  • Install Docker.

Building

Go to the project folder and run the following command to create an image:

docker image build . -t <image>

<image> should be replaced with a custom Docker image name.

Running Tests

docker container run <image> ctest --test-dir .. -VV

Running the Main Program

docker container run <image>

Building with Make

Currently Makefile does not support GoogleTest.

Building

Go to the project folder and run:

make

Running the Main Program

Go to the build folder and run:

./cpp-sample

Structure

.
β”œβ”€β”€ .github
β”‚   └── workflows
β”‚       └── build-test.yaml
β”œβ”€β”€ cmake
β”‚   └── hello.cmake
β”œβ”€β”€ docs
β”‚   └── badges
β”‚       β”œβ”€β”€ C++.svg
β”‚       β”œβ”€β”€ Linux.svg
β”‚       β”œβ”€β”€ Made-with-CMake.svg
β”‚       β”œβ”€β”€ Made-with-Make.svg
β”‚       β”œβ”€β”€ Made-with-Docker.svg
β”‚       β”œβ”€β”€ Made-with-GitHub-Actions.svg
β”‚       └── PowerShell.svg
β”œβ”€β”€ include
β”‚   └── foo
β”‚       └── foo.h
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ foo
β”‚   β”‚   β”œβ”€β”€ CMakeLists.txt
β”‚   β”‚   β”œβ”€β”€ foo.cpp
β”‚   β”‚   β”œβ”€β”€ private_foo_test.cpp
β”‚   β”‚   β”œβ”€β”€ private_foo.cpp
β”‚   β”‚   └── private_foo.h
β”‚   β”œβ”€β”€ CMakeLists.txt
β”‚   └── main.cpp
β”œβ”€β”€ tests
β”‚   β”œβ”€β”€ CMakeLists.txt
β”‚   └── foo_test.cpp
β”œβ”€β”€ .clang-format
β”œβ”€β”€ .gitignore
β”œβ”€β”€ Build-CMake.ps1
β”œβ”€β”€ CITATION.cff
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ Makefile
└── README.md