|
Dynalib Utils
|
| Build Status | |
|---|---|
| Github Actions | |
| Coverage Reports | |
| Docs | https://metaera.github.io/dynalib-utils/ |
Example C++11 CMake project that incorporates awesome Clang tooling, such as sanitizers, a code formatter, and code coverage reporting.
This repository is designed to be used as an example of how to set up a C++ project to use Clang tooling as well as be a template that can be copied and modified. Care has been taken to follow established C++ conventions whenever possible.
For more information about Clang, see the awesome-clang repository.
For C++ coding guidelines, see the C++ Core Guidelines.
You can use docker container to build code in this project on all OS's
You can run a container and map project code into directory to do all build processes.
Install required packages.
On Ubuntu 16.04 LTS, omit the
clang-toolspackage, which is included in theclangpackage on Ubuntu 16.04 LTS.
Set alternatives for tools use for test coverage.
Install Homebrew
Install required packages
The llvm formula is not installed into the user's PATH by default because it shadows tools such as clang that Apple provide. In order to use clang-tidy and LLVM code coverage tools, we need those in the PATH when cmake runs.
First install the EPEL repository.
Next install the SCL repository.
Install required packages
Append -DCMAKE_BUILD_TYPE=Release or -DCMAKE_BUILD_TYPE=Debug to the cmake command arguments to specify release or debug builds.
**Note: On CentOS 7, replace the cmake command with scl enable llvm-toolset-7 'cmake3 -DCMAKE_CXX_COMPILER=clang++ ..'.**
Use -DWERROR=On option to treat compile warnings as errors.
First, perform a build as described in the Build section, then run the following commands in the build directory.
Unit tests are written using the Catch2 unit testing framework.
Documentation is built using Doxygen. To configure how the docs are built, modify docs/Doxyfile.
**Note: On CentOS 7 for all of the following Clang tool instructions, replace the cmake command with scl enable llvm-toolset-7 'cmake3 <OPTIONS> ..'.**
The Clang Static Analyzer finds bugs in C/C++ programs at compile time.
Note: Not available on CentOS 7.
Clang-Tidy is configured using the .clang-tidy configuration file. Modify this file to control which checks should be run and configure parameters for certain checks.
For real projects, you'll likely want to modify this configuration file and disable certain checks you feel are too pedantic or don't match your project needs.
AddressSanitizer is a fast memory error detector. It consists of a compiler instrumentation module and a run-time library. The tool can detect the following types of bugs:
It is similar in functionality to Valgrind, but runs much faster and is able to catch a wider variety of bugs.
The UndefinedBehaviourSanitizer modifies the program at compile-time to catch various kinds of undefined behavior during program execution, for example:
Clang source-based code coverage provides metrics on which lines are covered by tests.
Clang-Format is a tool that can automically format your source code accordiing to a specific style guide, saving developers time. It is configured using the .clang-format configuration file. Modify this file to control how source files should be formatted.
To demonstrate clang-format in action, first modify a line from src/main.cpp
To
Next, run clang-format on the project.
src/main.cpp will be reformatted properly to
Cppcheck is a static analysis tool for C/C++ code. To run on the project
1.8.13