Skip to content

suikan4github/template_application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

template_application

A template application for C++ with CMake and GoogleTest

Description

A CMake file template and sample C++ application which allows unit test by GoogleTest. This template application is :

  • Able to collaborate with Visual Studio CODE editor.
  • Build in GoogleTest which is downloaded automatically.
  • "src" directory for application source code.
  • "test" directory for unit tests.
  • std::thread aware.
  • Generate Gcov data files during test ( except Windows platform )
  • Tested:
    • Ubuntu 20.04 with GCC.
    • Windows 11 with Visual Studio C++ compiler.
    • WSL2 with VS CODE remote server.
  • Automatically tested by GitHub Actions.
    • linux-latest, Debug (With gcovr report)
    • linux-latest, Release
    • windows-latest, Debug
    • windows-latest, Release

Screenshot

Requirement

Ubuntu

  • Ubuntu 20.04
  • VS Code
  • CMake 3.15 or newer
  • Python 3
  • g++

Windows

  • Windows 10 or 11
  • VS Code
  • CMake 3.15 or newer
  • Python 3
  • Microsoft Visual C++ compiler

WSL2

Usage

Visual Studio CODE

Run the followings command inside this directory ( Where README.md exists) to start the VS CODE:

code .

Inside VS CODE, Type Ctrl-Shift-P to show the command pallet. And then, execute following command :

CMake: Configure

Now, you can build, run the executable and Ctest from the status bar of the VS CODE.

Command line

Run the followings commands inside this directory ( Where README.md exists) :

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

The executables are stored in the subdirectories:

  • build/src
  • build/test

In the case of MS Visual Studio C, the executables are located under the build configuration subdirectories like :

  • build/src/Debug, build/src/Release
  • build/test/Debug, build/test/Release

To run the Ctest, type :

ctest

Install

Ubuntu

Run followings on the shell.

sudo snap install code --classic
sudo apt-get install build-essential cmake doxygen

Windows

Run followings on the PowerShell or Command .

winget install Microsoft.VisualStudioCode -e
winget install Kitware.CMake -e
winget install Microsoft.VisualStudio.2022.Community -e
winget install Git.Git -e
winget install Python.Python.3 -e
winget install doxygen -e
winget install graphviz -e
  • Note 1: After installing VS CODE, install the C++ Extension Pack and the Gcov Viewer extension to the VS CODE.
  • Note 2: The above winget install the CMake installer only. Run the CMake once and complete the installation.
  • Note 3: The above wget install the VisualStudio launcher only. Install the C++ workload after winget installation.

After the installation, set the PATH environment variable for CMake, Visual Studio, Git and Graphviz.

WSL2

Run followings on the PowerShell or Command to install the Visual Studio CODE editor.

winget install Microsoft.VisualStudioCode -e

Then, run followings on the Ubuntu shell.

sudo apt-get install build-essential cmake doxygen ca-certificates

Customize the project

To change the project name, edit the CMakeLists.txt and change following line :

project("template_application")

The quoted string is the project name.

License

This project is shared with the MIT License.

About

A template application for C++ with CMake and GoogleTest

Resources

License

Stars

Watchers

Forks

Packages

No packages published