Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Latest commit

ย 

History

History
146 lines (109 loc) ยท 2.86 KB

README.md

File metadata and controls

146 lines (109 loc) ยท 2.86 KB

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
โ”‚       โ”œโ”€โ”€ cmake-gtest.yaml
โ”‚       โ”œโ”€โ”€ docker.yaml
โ”‚       โ””โ”€โ”€ make.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