Skip to content

fridaythe14th/CProjectTemplate

 
 

Repository files navigation

Template For C Projects

C License Build CI Test codecov

This is a template for C projects. What you get:

  • Library, executable and test code separated in distinct folders.
  • Use of modern CMake for building and compiling.
  • External libraries fetched by CMake or cloned by Git.
  • Unit testing using Unity
  • General purpose libraries:
  • Continuous integration testing with Github Actions.
  • Code coverage reports, including automatic upload to Codecov.
  • Code documentation with Doxygen.

Structure

├── CMakeLists.txt
├── app
│   ├── CMakesLists.txt
│   └── main.c
├── cmake
│   └── cmake modules
├── docs
│   ├── Doxyfile
│   └── html/
├── external
│   ├── CMakesLists.txt
│   ├── ...
├── src/my_lib
│   ├── CMakesLists.txt
│   ├── my_lib.h
│   └── my_lib.c
└── tests
    ├── CMakeLists.txt
    └── main.c

Library code goes into src/, main program code in app/ and tests go in tests/.

Software Requirements

  • CMake 3.16+
  • GNU Makefile
  • Doxygen
  • MSVC 2017 (or higher), GCC 9 (or higher), Clang 9 (or higher)
  • Code Coverage (only on GNU|Clang): lcov, gcovr

Building

First, clone this repo and do the preliminary work:

git clone --recursive https://github.com/franneck94/CProjectTemplate
make prepare
  • App Executable
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --target main
cd app
./main
  • Unit testing
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug --target unit_tests
cd tests
./unit_tests
  • Documentation
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . --config Debug --target docs
  • Code Coverage (Unix only)
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
cmake --build . --config Debug --target coverage

For more info about CMake see here.

About

franneck94 CProjectTemplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 51.2%
  • Python 44.9%
  • C 3.2%
  • Makefile 0.7%