6/20/2023 0 Comments Modern cmake![]() ![]() This approach makes it trivial for third-party projects to re-use the projects library code. To keep the template modular, all subprojects derived from the library have been separated into their own CMake modules. Simply remove the standalone / documentation directory and according github workflow file.Ĭan I build the standalone and tests at the same time? / How can I tell my IDE about all subprojects? I don't need a standalone target / documentation. See here for an example header-only library based on the template. Yes, however you will need to change the library type to an INTERFACE library as documented in the CMakeLists.txt. FAQĬan I use this for header-only libraries? CcacheĬcache can be enabled by configuring with -DUSE_CCACHE=. clang-format.Īdditional arguments can be passed to the analyzers by setting the CLANG_TIDY_ARGS, IWYU_ARGS or CPPCHECK_ARGS variables. Static Analyzers can be enabled by setting -DUSE_STATIC_ANALYZER=, or a combination of those in quotation marks, separated by semicolons.īy default, analyzers will automatically find configuration files such as. Sanitizers can be enabled by configuring CMake with -DUSE_SANITIZER=. The test and standalone subprojects include the tools.cmake file which is used to import additional tools on-demand through CMake configuration arguments. Use the following command to build and run the executable target.Ĭmake -build build -target GenerateDocs Additional tools 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.ĭuring development it is usually convenient to build all subprojects at once. ![]() Add your project's codecov token to your project's github secrets under CODECOV_TOKENĮventually, you can remove any unused files, such as the standalone directory or irrelevant github workflows for your project.įeel free to replace the License with one suited for your project.For header-only libraries: see the comments in CMakeLists.txt.Remember to rename the include/greeter directory to use your project's lowercase name and update all relevant #includes accordingly.Capitalization matters here: Greeter means the name of the project, while greeter is used in file names.Replace all occurrences of "Greeter" in the relevant CMakeLists.txt with the name of your project.Automatic documentation and deployment with Doxygen and GitHub Pages.Installable target with automatic versioning information and header generation via PackageProject.cmake.Reproducible dependency management via CPM.cmake.Code formatting enforced by clang-format and cmake-format via Format.cmake.Continuous integration via GitHub Actions.Clean separation of library and executable code.Suited for single header libraries and projects of any scale.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. 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.
0 Comments
Leave a Reply. |