Skip to content

akmaru/cpp-template

Repository files navigation

C++ Template: A template project for C/C++

Features

Development environment setup

Initialize

At first, you need to set environment variables referenced by docker-compose.yml.

./docker/init_env.sh

Build and launch Docker Image

You can build and launch the development environment by using Docker Compose

docker-compose build
docker-compose run dev

or, you can also do it by using VSCode devcontainer, by executing Dev Containers: Open Folder in Container... and select the project's root directory.

Build

You can configure by using CMake and build fastly by using Ninja

cmake -B build -GNinja
cmake --build build

Test

You can test by running CTest. The project uses Google Test as the test framework.

ctest --test-dir build

Benchmark

The project uses Google Benchmark as the benchmark framework.

./build/bin/cpp-template_benchmark

You can get the following result:

2023-02-26T12:31:10+00:00
Running ./build/bin/cpp-template_benchmark
Run on (80 X 3383.81 MHz CPU s)
CPU Caches:
  L1 Data 32 KiB (x40)
  L1 Instruction 32 KiB (x40)
  L2 Unified 256 KiB (x40)
  L3 Unified 51200 KiB (x2)
Load Average: 2.95, 3.46, 3.50
-------------------------------------------------------
Benchmark             Time             CPU   Iterations
-------------------------------------------------------
BM_vadd/8           114 ns          114 ns      6336100
BM_vadd/64          276 ns          276 ns      2492204
BM_vadd/512        1342 ns         1342 ns       533077
BM_vadd/4096      10032 ns        10030 ns        71436
BM_vadd/8192      19511 ns        19506 ns        36428

Format check

C/C++ source code

find . -type f -name "*.h" -not -path './build/*' -or -name "*.cc" -not -path './build/*' | xargs clang-format --dry-run -Werror

CMake

find . -type f -name "CMakeLists.txt" -not -path './build/*' -or -name "*.cmake" -not -path './build/*' | xargs cmake-format --check

Lint check

find . -type f -name "*.h" -not -path './build/*' -or -name "*.cc" -not -path './build/*' | xargs clang-tidy -p build

Build package

cd build
cpack -G "TGZ"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages