- Description
- Features
- Initialization
- Building
- Using QT
- Testing
- Formatting
- Static analyzers
- Code coverage
- Documentation
- Packaging
- Coming Features
- Contributing
- Author
- License
- References
A template for C++ projects featuring CI, building, testing, formatting, documentation, and more.
Designed as a starting point with a wide range of features that can be easily included or excluded based on your needs.
This template reflects my personal approach, so you may have different preferences regarding its implementation.
Any feedback is greatly appreciated!
# | Feature | CI | Description |
---|---|---|---|
License | N/A | Fully open license. The project is licensed under the Unlicense | |
MD templates | N/A | Attractive main README (Logo, Badges, Quick Links, Tables, Diagrams, References) | |
Static analysis | Yes | By CppCheck GitHub Action | |
Code Checks | Yes | By Python scripts: TBD | |
Building | Yes | Build with Ninja and CMake, Use of Ccache to speed up the rebuilds | |
Testing | Yes | Unit testing with GTest and CTests (with an option to enable), uploading results to GitHub | |
Coverage | Yes | Using GCov and LCov, ziping by 7xip, uploading report to GitHub | |
Formatting | Yes | Using clang-format and Google code style configuration - to format C and CPP code | |
Packaging | Yes | Stripping binaries, ziping by 7xip, uploading binaries to GitHub, Windows package by WiX | |
Documentation | Yes | Using Doxygen, Publishing documentation on GitHub Pages | |
CI | Yes | Using GitHub Actions CI workflows for Windows, Linux and MacOS operation systems | |
gitignore | N/A | Uses well known ignore file from this repo | |
QT | Yes | Installed on CI only |
What is important - you can easialy disable the things you don't use.
There are two ways to install the project:
- clone if from GitHub
- use this repo as template
If you would like to clone the repository please run:
git clone https://github.com/dimanikulin/capable-cpp-template/
You need to provide an icon at ./resources/icons/main.png if you wish to include an icon in this README file.
Update the href in badges to point to your repository (note: the repository must be public to use badges)
GitHub supports Mermaid.js for creating diagrams, such as:
flowchart LR
B -->|Multimedia data| C(Online Multimedia IR system)
B -->|Multimedia data| D(Offline Multimedia IR system)
A(Photo Album owner) --> B(FVA Solution)
A(Photo Album owner) --> D1
A(Photo Album owner) --> D2
A(Photo Album owner) --> D3
D1(fa:fa-tablet Tablet) -->|Multimedia data| B(FVA Solution)
D2(fa:fa-phone Phone) -->|Multimedia data| B(FVA Solution)
D3(fa:fa-hdd-o External Disk) -->|Multimedia data| B(FVA Solution)
Then please update "Project"
in CMakeLists.txt
project(
"Project"
VERSION 0.1.0
LANGUAGES CXX
)
with your project name.
To build the project you will need to run CMake routine like to the one below:
mkdir build/ && cd build/
cmake --build .
You can build it locally and in a CI environment.
The template uses Google Test for unit testing.
Unit testing is enabled by default via the BUILD_TESTS
option.
To run tests, use CTest from the build directory:
cd build
ctest -C Release
Tests can be executed both locally and in a CI environment.
Make sure to have the same version of g++ and gcov, otherwize you will see a report creation issue. Use sudo update-alternatives to fix that.
First of all you will need to install coverage tool by
sudo apt-get update
sudo apt-get -y install lcov
Then you will need to run the capture for coverage
lcov --capture --directory ./build --output-file ./build/coverage.info --ignore-errors mismatch
Cause the coverage report must be clear it is suggested to run filtering
lcov --remove ./build/coverage.info --directory ./build -o ./build/filtered_coverage.info \
'/usr/include/*' \
'/include/gtest/*' \
'*/test/*' \
'*/googletest/*'
Last but not least there will be translation coverage report to html format
genhtml ./build/filtered_coverage.info --output-directory coverage_report
Windows is supported now only by using Wix.
Prerequisites - clang-format 17 or later and its configuration in file .clang-format
Installing clang-format
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
sudo apt install clang-format-17
rm ./llvm.sh
For reformatting please run following cmds:
find tests -regex '.*\.\(cpp\|h\|cc\|cxx\)' -exec clang-format-17 -i {} \;
find src -regex '.*\.\(cpp\|h\|cc\|cxx\)' -exec clang-format-17 -i {} \;
Please see releaseDocs.yml for more details
Now supported on CI only.
Please refer to codeChecks.yml to see implementation for CppCheck
Also this code might be used for static analyzing based on clang
clang-tidy:
stage: clang-tidy
script:
- cmake -Bbuild_stat_analyser -H. -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D BUILD_TESTING=OFF
- cd build_stat_analyser
- run-clang-tidy-17 -warnings-as-errors='*' -config-file ../.clang-tidy
allow_failure: true
- QT support (CI and local)
- Package manager support for Mac and Linux
- CMake formatting
- Versioning
- Codes
- MarkDown Lint
- Dockerfile
- Qt-oriented static code analyzer based on the Clang framework
- find merging symbols like "<<<"
- clang-tidy
- code checks
You will need to update in boilerplate.txt to start using this check. Also please uncomment run of boilerplate_check.py in codeChecks.yml
TBD
This project is licensed under the Unlicense - see the LICENSE file for details
# | Name | Source | Release date | Author | Description |
---|---|---|---|---|---|
1 | gitignore repository | GitHub Repo | TBD | TBD | TBD |
2 | QT Static analizer repository | GitHub Repo | TBD | TBD | TBD |
3 | Cpp project template repository | GitHub Repo | TBD | TBD | TBD |
4 | Google Tests repository | GitHub Repo | TBD | TBD | TBD |