This project serves as a template for consistent, cross-platform, open-source C++ library development.
One goal is to make it as simple as possible to go from cloning to a tested build with as few steps as possible. The general process should be as simple as:
cmake .
cmake --build . --config Release
ctest -C Release
- root
- cmake
- docs
- examples
- include
- src
- test
- vendor
This setup relies on the projects being managed in a Git repository.
Manages the overall build with specific scripts for handling:
- Defaulting build type (i.e., Release)
- Uniform compiler flags
- Identifying build target architecture (i.e., operating system, compiler, and CPU instruction architecture) (TODO)
- Automatic versioning based on Git repository tags
- Optional static or dynamic libraries
- Handling of MSVC and Windows specific requirements (e.g., MT/MD flags, export headers)
Where possible, dependencies are added using git submodules. In a few exceptional cases, a dependency may be vendored directly in the root repository.
Consistent approach to handling error callbacks.
Unit tests are created by googletest and automatically detected by CTest and added to the test suite
The simplest way to implement formatting using the .clang-format file is to integrate clang format support into your IDE, which can be configured to automatically format code upon file-save. Else,
- On Windows, Visual Studio, set up clang format execution rules using Tools > Options > Text Editor > C/C++ > Formatting
- On Mac,
brew install clang-format
and run at the command line withclang-format -i <file>
- On Ubuntu,
sudo apt install clang-format
and run at the command line withclang-format -i <file>
NOTE: ensure the version of clang-format your development team is using locally matches the version used
in .github/workflows/clang-format-check.yml
or you may get false errors. The .clang-format file can be set to a
version earlier than your current.
Automatic builds, testing, packaging, and deployment.
Be sure to use your own copyright for your projects using this structure.