This is a basic template to create a C/C++ project. Compilation process is handled by CMake. Unit tests are provided by the Google Test framework. The Google Test libraries will be downloaded and built by CMake. Code coverage analysis is provided by gcov
and lcov
.
- CMake
- A C/C++ compiler. I have only tried the code coverage with
GCC
, I am not sure if it will work withclang
.
- Put all header files on
include/
folder. Source files go insidesrc/
. - Go into the
CMakeLists.txt
file and change the project name. Include all your source files in this file. - For the
CMakeLists.txt
inside thetests
folder, include the unit tests source files and the project source files as well.
Go into your project root folder and run these commands:
mkdir build
cd build
cmake ..
make
The executable for the program and the unit tests will be in the bin/
folder.
Go into your project root folder and run these commands:
cd build
cmake -DCMAKE_BUILD_TYPE=Coverage ..
make
make coverage
The executable for the program and the unit tests will be in the bin/
folder. Code coverage information will be in the build/coverage
folder. Use a web browser to open the index.html
file.