This is a minimal implementation of a modern C++ project.
The repository gives examples for the following:
- CMake
- Using submodules (Catch2, args, json)
- Finding library (HDF5 but not required to compile)
- Enabling OpenMP (but not required)
- Git versioning (i.e. automatic versioning by git hash)
- Creating a library
- Creating an executable
- C++ templates, concepts (C++-20 feature)
- Creating unit tests
- Error handling
with my taste on software engineering (e.g. naming convention and file structure).
This can be used as a template for your next C++ project, so that you don't need
to copy the same snippets again. Make sure to change the name to your own project -
you will be replacing TEMPLATE / Template / template
names except the
actual template
keyword for C++ in src/util/vectorization.h
.
You can also checkout to other branches to see C++ template with modules. For
example, you can checkout to mpi
to have an MPI-C++ template.
To compile, you will be doing:
- clone the repository with all the submodules
git clone --recursive https://github.com:Walter-Feng/cpp-template.git
- make a build directory
cd cpp-template
mkdir build
cd build
- run cmake
cmake ..
- make
make -j
- run the executable
./template
- run the unit test
test/test_template