Projective geometric for modern C++.
- constexpr-aware
- branchless computation
- Use C++20 concepts
- Modern CMake practices
- Integrated test suite
- Continuous integration via GitHub Actions
- Code coverage via codecov
- Code formatting enforced by clang-format and cmake-format via Format.cmake
- Reproducible dependency management via CPM.cmake
- Installable target with automatic versioning information and header generation via PackageProject.cmake
- Automatic documentation and deployment with Doxygen and GitHub Pages
- Support for sanitizer tools, and more
- Use this repo as a template.
- Replace all occurrences of "ProjGeom" in the relevant CMakeLists.txt with the name of your project
- Capitalization matters here:
ProjGeom
means the name of the project, whileprojgeom
is used in file names. - Remember to rename the
include/projgeom
directory to use your project's lowercase name and update all relevant#include
s accordingly.
- Capitalization matters here:
- Replace the source files with your own
- For header-only libraries: see the comments in CMakeLists.txt
- Add your project's codecov token to your project's github secrets under
CODECOV_TOKEN
- Happy coding!
Eventually, you can remove any unused files, such as the standalone directory or irrelevant github workflows for your project. Feel free to replace the License with one suited for your project.
To cleanly separate the library and subproject code, the outer CMakeList.txt
only defines the library itself while the tests and other subprojects are self-contained in their own directories.
During development it is usually convenient to build all subprojects at once.
Use the following command to build and run the executable target.
cmake -S. -B build
cmake --build build
./build/standalone/ProjGeom --help
Use the following commands from the project's root directory to run the test suite.
cmake -S. -B build
cmake --build build
cd build/test
CTEST_OUTPUT_ON_FAILURE=1 ctest
# or maybe simply call the executable:
./build/test/ProjGeomTests
To collect code coverage information, run CMake with the -DENABLE_TEST_COVERAGE=1
option.
Use the following commands from the project's root directory to check and fix C++ and CMake source style. This requires clang-format, cmake-format and pyyaml to be installed on the current system.
cmake -S . -B build/test
# view changes
cmake --build build --target format
# apply changes
cmake --build build --target fix-format
See Format.cmake for details.
The documentation is automatically built and published whenever a GitHub Release is created. To manually build documentation, call the following command.
cmake -S . -B build
cmake --build build --target GenerateDocs
# view the docs
open build/documentation/doxygen/html/index.html
To build the documentation locally, you will need Doxygen, jinja2 and Pygments on installed your system.
The test and standalone subprojects include the tools.cmake file which is used to import additional tools on-demand through CMake configuration arguments. The following are currently supported.
Sanitizers can be enabled by configuring CMake with -DUSE_SANITIZER=<Address | Memory | MemoryWithOrigins | Undefined | Thread | Leak | 'Address;Undefined'>
.
Static Analyzers can be enabled by setting -DUSE_STATIC_ANALYZER=<clang-tidy | iwyu | cppcheck>
, or a combination of those in quotation marks, separated by semicolons.
By default, analyzers will automatically find configuration files such as .clang-format
.
Additional arguments can be passed to the analyzers by setting the CLANG_TIDY_ARGS
, IWYU_ARGS
or CPPCHECK_ARGS
variables.
Ccache can be enabled by configuring with -DUSE_CCACHE=<ON | OFF>
.
- ModernCppStarter & PVS-Studio Static Code Analyzer: Official instructions on how to use the ModernCppStarter with the PVS-Studio Static Code Analyzer.
- lefticus/cpp_starter_project: A popular C++ starter project, created in 2017.
- filipdutescu/modern-cpp-template: A recent starter using a more traditional approach for CMake structure and dependency management.
- vector-of-bool/pitchfork: Pitchfork is a Set of C++ Project Conventions.