diff --git a/index.html b/index.html index a15e937..9a21ce4 100644 --- a/index.html +++ b/index.html @@ -51,23 +51,23 @@
Setting up a new C++ project usually requires a significant amount of preparation and boilerplate code, even more so for modern C++ projects with tests, executables and continuous integration. This template is the result of learnings from many previous projects and should help reduce the work required to setup up a modern C++ project.
Greeter
means the name of the project, while greeter
is used in file names.include/greeter
directory to use your project's lowercase name and update all relevant #include
s accordingly.CODECOV_TOKEN
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 -Hstandalone -Bbuild/standalone +ModernCppStarter
Setting up a new C++ project usually requires a significant amount of preparation and boilerplate code, even more so for modern C++ projects with tests, executables and continuous integration. This template is the result of learnings from many previous projects and should help reduce the work required to setup up a modern C++ project.
Features
- Modern CMake practices
- Suited for single header libraries and projects of any scale
- Clean separation of library and executable code
- 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
Usage
Adjust the template to your needs
- Use this repo as a template.
- Replace all occurrences of "Greeter" in the relevant CMakeLists.txt with the name of your project
- Capitalization matters here:
Greeter
means the name of the project, whilegreeter
is used in file names.- Remember to rename the
include/greeter
directory to use your project's lowercase name and update all relevant#include
s accordingly.- 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.Build and run the standalone target
Use the following command to build and run the executable target.
cmake -S standalone -B build/standalone cmake --build build/standalone -./build/standalone/Greeter --helpBuild and run test suite
Use the following commands from the project's root directory to run the test suite.
cmake -Htest -Bbuild/test +./build/standalone/Greeter --helpBuild and run test suite
Use the following commands from the project's root directory to run the test suite.
cmake -S test -B build/test cmake --build build/test CTEST_OUTPUT_ON_FAILURE=1 cmake --build build/test --target test # or simply call the executable: -./build/test/GreeterTestsTo collect code coverage information, run CMake with the
-DENABLE_TEST_COVERAGE=1
option.Run clang-format
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 -Htest -Bbuild/test +./build/test/GreeterTestsTo collect code coverage information, run CMake with the
-DENABLE_TEST_COVERAGE=1
option.Run clang-format
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 test -B build/test # view changes cmake --build build/test --target format # apply changes -cmake --build build/test --target fix-formatSee Format.cmake for details.
Build the documentation
The documentation is automatically built and published whenever a GitHub Release is created. To manually build documentation, call the following command.
cmake -Hdocumentation -Bbuild/doc +cmake --build build/test --target fix-formatSee Format.cmake for details.
Build the documentation
The documentation is automatically built and published whenever a GitHub Release is created. To manually build documentation, call the following command.
cmake -S documentation -B build/doc cmake --build build/doc --target GenerateDocs # view the docs -open build/doc/doxygen/html/index.html
To build the documentation locally, you will need Doxygen, jinja2 and Pygments on installed your system.
Build everything at once
The project also includes an
all
directory that allows building all targets at the same time. This is useful during development, as it exposes all subprojects to your IDE and avoids redundant builds of the library.cmake -Hall -Bbuild +open build/doc/doxygen/html/index.htmlTo build the documentation locally, you will need Doxygen, jinja2 and Pygments on installed your system.
Build everything at once
The project also includes an
all
directory that allows building all targets at the same time. This is useful during development, as it exposes all subprojects to your IDE and avoids redundant builds of the library.cmake -S all -B build cmake --build build # run tests