{"id":15988286,"url":"https://github.com/kolbma/cpp-experiments-cmake-template","last_synced_at":"2026-04-29T17:31:20.510Z","repository":{"id":245865686,"uuid":"819347668","full_name":"kolbma/cpp-experiments-cmake-template","owner":"kolbma","description":"The C++ Experiments CMake Template is a project template for modern C++ projects with CMake buildsystem and Visual Studio Code IDE","archived":false,"fork":false,"pushed_at":"2024-06-24T17:02:12.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-15T13:42:21.487Z","etag":null,"topics":["clang-tidy","codeql-enabled","cplusplus","cppcheck","doxygen-awesome-css","flawfinder","safe","template-project"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kolbma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-24T10:22:40.000Z","updated_at":"2024-06-24T17:35:04.000Z","dependencies_parsed_at":"2024-06-24T14:52:32.453Z","dependency_job_id":"a11bf3c2-35f1-4ac9-b629-d45e286c4259","html_url":"https://github.com/kolbma/cpp-experiments-cmake-template","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"842af74468ce759eaa0f65ad26c8eccdd5fbd411"},"previous_names":["kolbma/cpp-experiments-cmake-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kolbma/cpp-experiments-cmake-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbma%2Fcpp-experiments-cmake-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbma%2Fcpp-experiments-cmake-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbma%2Fcpp-experiments-cmake-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbma%2Fcpp-experiments-cmake-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kolbma","download_url":"https://codeload.github.com/kolbma/cpp-experiments-cmake-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolbma%2Fcpp-experiments-cmake-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32436574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T17:26:39.753Z","status":"ssl_error","status_checked_at":"2026-04-29T17:25:53.857Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang-tidy","codeql-enabled","cplusplus","cppcheck","doxygen-awesome-css","flawfinder","safe","template-project"],"created_at":"2024-10-08T04:02:32.501Z","updated_at":"2026-04-29T17:31:20.495Z","avatar_url":"https://github.com/kolbma.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Experiments CMake Template\n\n![Build](https://github.com/kolbma/cpp-experiments-cmake-template/actions/workflows/safe-cplusplus-build.yml/badge.svg)\n![CodeQL](https://github.com/kolbma/cpp-experiments-cmake-template/actions/workflows/codeql.yml/badge.svg)\n![Coverage](https://img.shields.io/endpoint?style=flat-square\u0026url=https%3A%2F%2Fgist.githubusercontent.com%2Fkolbma%2Fd7b822a2fd65dc027c2cc661184207aa%2Fraw%2Fcpp-experiments-cmake-template-cobertura-coverage.json)\n\nThe _C++ Experiments CMake Template_ is a project template for modern\nC++ projects with the\n[_CMake_](https://cmake.org/cmake/help/latest/index.html) build system\nand Visual Studio [Code](https://code.visualstudio.com/) as a \ndevelopment environment.  \n\nThe default setting is the __C++23__ standard.\n\n## Components\n\n1. C++ Compiler\n\nGCC and CLang are supported in current versions with sufficient\nC++23 support. Testing is carried out with GCC 14 and CLang 18.\n\n2. LTO Support\n\nIf the installed compiler/linker supports LTO, this is activated by \ndefault.\n\nDisable with __ENABLE_LTO=OFF__.\n\n3. ccache/sccache Support\n\nIf the programs __ccache__ or __sccache__ are installed and found by\nCMake, these compiler caches are used for build and linking. \n\nDisable with __ENABLE_CCACHE=OFF__.\n\n4. Compiler Warnings\n\nVery strict compiler warnings in order to create error-free, secure and\nmultiplatform-compatible code.\n\nWith the CMake option _ENABLE_WARNINGS_AS_ERRORS_ these warnings can \nalso be degraded to errors.  \nSo set __ENABLE_WARNINGS_AS_ERRORS=ON__.\n\nTo disable all the compiler warnings setup set __ENABLE_WARNINGS=OFF__.\n\n5. Code Checks\n\nProvided the tools are installed in the development environment,\nthey are used to check the created source code.  \nBuild targets are also available in CMake.\n\n* clang-tidy (Disable with __ENABLE_CLANG_TIDY=OFF__)\n* cppchecker (Disable with __ENABLE_CPPCHECK=OFF__)\n* flawfinder (Disable with __ENABLE_FLAWFINDER=OFF__)\n\n6. Sanitizer Compile Options\n\nThe following sanitizer options are optionally available for compiling:\n\n* ENABLE_SANITIZE_ADDR \"Enable address sanitize.\"\n* ENABLE_SANITIZE_UNDEF \"Enable undefined sanitize.\"\n* ENABLE_SANITIZE_LEAK \"Enable leak sanitize.\"\n* ENABLE_SANITIZE_THREAD \"Enable thread sanitize.\"\n\n7. CPM CMake Package Manager\n\nWith [CPM](https://github.com/cpm-cmake/CPM.cmake), external \ndependencies for the project can be added very easily during the build \nprocess.\n\n8. Doxygen Code Documentation\n\nIf installed on the system, the code documentation tool \n[Doxygen](https://www.doxygen.nl/) is activated and provides the build \ntarget __docs__ for the creation of HTML documentation in the _docs_ \nsubfolder.  \nThe theme \n[doxygen-awesome-css](https://jothepro.github.io/doxygen-awesome-css)\nis used.  \nThe files in the _doxygen_ folder can be edited for customisation.\n\nDisable with __ENABLE_DOXYGEN=OFF__.\n\n9. CTest and Catch2 Testing\n\nTests are using _CTest_ of _CMake_.\n\nIt can be disabled by setting __BUILD_TESTING=OFF__.\n\n[Catch2](https://github.com/catchorg/Catch2) is installed automatically \n(can be deactivated) and can be used for unit tests.  \nOptionally, any other tool can be installed, e.g. with _CPM_.\n\nDisable with __ENABLE_CATCH2_TEST=OFF__.\n\n9. Code Coverage of Tests\n\nCode coverage report in tests can be enabled with\n__ENABLE_COVERAGE=ON__.\n\nThe external tool [__gcovr__](https://gcovr.com) is required for this to\nwork. Any version \u003e= 5.0 should do.\n\nTo run the coverage report the _CMake__ target __coverage__ is to be\nused.  \nThe compilation and linking is done with special flags and additional\nlib. So this should be only enabled to generate a report.\n\nA textual report is in the console output and the _Cobertura_ XML format\nin saved in _build/gcov/cobertura-coverage.xml_.\n\nOptional configuration can be done in file _gcovr.cfg_.\n\nWith\n[GaelGirodon/ci-badges-action](https://github.com/GaelGirodon/ci-badges-action)\nGitHub Workflow Action a badge can be created like in this template.\n\n10. GitHub Workflow\n\nThere is provided the `safe-cplusplus-build.yml` workflow for GitHub.  \nIt does source and safety checks provided by the multiple CMake targets\ncreated by helper functions of this template.  \nAfter build of _Debug_ and _Release_ config the tests are running.  \nOn any failure the workflow fails.\n\n## Organisation of the Project Structure\n\nThere are the subfolders _apps_, _include_, _src_ and _tests_.  \n\n_apps_ is intended for the sources of applications  \n_include_ is the base of the usual include files  \n_src_ is for shared source components for building objects or libraries.\n_tests_ is the subfolder for unit tests \n\nThese folders contain _CMakeLists.txt_ files, each of which \nautomatically involve further _CMakeLists.txt_ files in deeper \nsubfolders and thus a tree structure can be created very easily.\n\nBased on the existing example code in the folders, it should be\ncomprehensable how you can adapt the structure for your own project.\n\nThe _include_ folder is added to the default includes of compiler.\n\n## _custom_target_ Magic\n\nThe provided _CMakeLists.txt_ in subfolders of the template project \ncontains the usage of CMake helper functions out of \n`cmake/custom_target.cmake`.  \n\nSo for _apps_ this might look like:\n```\ninclude(custom_target)\n\nset(TARGET_NAME env_crashloop)\ncreate_executable(${TARGET_NAME} env_crashloop.cpp)\ntarget_link_libraries(${TARGET_NAME} PRIVATE -lpthread)\n```\n\nThe `create_executable(${TARGET_NAME} \u003csource files...\u003e)` make the\nrequired CMake setup to compile the code like intended and provides\nuseful CMake targets.  \nAfterwards you can call any CMake function on the target which makes\nsense for your project.\n\nThe example libraries in _src_ are using a quite simple \n_CMakeLists.txt_ with comparable purpose:\n```\ninclude(custom_target)\n\nset(TARGET_NAME liba)\ncreate_library(${TARGET_NAME} lib.cpp)\n```\n\nFor unit tests using _CTest_ like in the sample `bare_test`:\n```\ninclude(custom_target)\n\nif(BUILD_TESTING)\n  set(TEST_NAME bare_test)\n  create_test(${TEST_NAME})\n  add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})\n  # target_link_libraries(${TEST_NAME} PRIVATE liba)\nendif()\n```\n\nThere you have to call at least \n[`add_test()`](https://cmake.org/cmake/help/latest/command/add_test.html)\nprovided by CMake.\n\nFor unit tests with the _Catch2_ framework like in `catch2_a_test`:\n```\ninclude(custom_target)\n\nif(ENABLE_CATCH2_TEST)\n  set(TEST_NAME sum_tests)\n  create_test(${TEST_NAME})\n  target_link_libraries(${TEST_NAME} PRIVATE liba)\nendif()\n```\n\nHere the addition of tests for _CTest_ is handled by _Catch2_ and you\nmust not call `add_test()` yourself.\n\n## License\n\n[BSD 1-Clause License](https://spdx.org/licenses/BSD-1-Clause.html)\n\nCopyright (c) 2024 Markus Kolb All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n1. Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n“AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\nPARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolbma%2Fcpp-experiments-cmake-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkolbma%2Fcpp-experiments-cmake-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolbma%2Fcpp-experiments-cmake-template/lists"}