{"id":18260010,"url":"https://github.com/hungrybluedev/cmake-basic-c-template","last_synced_at":"2025-06-12T08:33:38.393Z","repository":{"id":109592035,"uuid":"289223589","full_name":"hungrybluedev/CMake-Basic-C-Template","owner":"hungrybluedev","description":"This repository contains a basic CMake template that can be used a viable starting point for a moderate to large C codebase.","archived":false,"fork":false,"pushed_at":"2020-09-29T14:06:56.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T18:36:26.380Z","etag":null,"topics":["c","cmake","project","template"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hungrybluedev.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":"2020-08-21T08:53:14.000Z","updated_at":"2022-01-18T08:19:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3fa7b69-ee24-46b7-aec5-351969b266a5","html_url":"https://github.com/hungrybluedev/CMake-Basic-C-Template","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2FCMake-Basic-C-Template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2FCMake-Basic-C-Template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2FCMake-Basic-C-Template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungrybluedev%2FCMake-Basic-C-Template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hungrybluedev","download_url":"https://codeload.github.com/hungrybluedev/CMake-Basic-C-Template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247947825,"owners_count":21023058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["c","cmake","project","template"],"created_at":"2024-11-05T10:41:32.356Z","updated_at":"2025-04-08T23:44:33.862Z","avatar_url":"https://github.com/hungrybluedev.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Template for CMake based C Projects\n\n## Badges\n\n| Description | Badges                                                                                                                                                                                                                                                                                                                                                      |\n| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| LGTM        | [![LGTM Grade](https://img.shields.io/lgtm/grade/cpp/github/hungrybluedev/CMake-Basic-C-Template)](https://lgtm.com/projects/g/hungrybluedev/CMake-Basic-C-Template/context:cpp) [![LGTM Alerts](https://img.shields.io/lgtm/alerts/github/hungrybluedev/CMake-Basic-C-Template)](https://lgtm.com/projects/g/hungrybluedev/CMake-Basic-C-Template/alerts/) |\n| Codacy      | [![Codacy grade](https://img.shields.io/codacy/grade/0963bb8a14b14ddcb5e6d5cdcbe7b704)](https://www.codacy.com/)                                                                                                                                                                                                                                            |\n| License     | [![GitHub](https://img.shields.io/github/license/hungrybluedev/CMake-Basic-C-Template)](LICENSE)                                                                                                                                                                                                                                                            |\n| CI/CD       | [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/hungrybluedev/CMake-Basic-C-Template/Cross-platform%20CMake%20Builds?label=Cross-platform%20build)](https://github.com/hungrybluedev/CMake-Basic-C-Template/actions)                                                                                                               |\n| Version     | [![GitHub release (latest by date)](https://img.shields.io/github/v/release/hungrybluedev/CMake-Basic-C-Template)](https://github.com/hungrybluedev/CMake-Basic-C-Template/releases)                                                                                                                                                                        |\n\n## Introduction\n\nI wanted to use CMake as my default build system. However, the tutorials are mostly outdated and people share non-standard solutions online. I made this repository to avoid duplication of work and also to make use of the recommended guidelines wherever I could find them.\n\n## Read The CMakeLists.txt File\n\nThis file is meant to be read by humans. Developers must put effort into it so that it can serve as the documentation itself.\n\n## Commands\n\nTo generate the build files:\n\n```bash\n/path/to/src $ cmake -G\"Unix Makefiles\" -S . -B build\n```\n\nThis generates _Unix Makefiles_ for the src (`.`) in the build directory (`build`).\n\n- Type `cmake --help` for a list of available generators.\n- (Suggestion) Change `-B build` to `-B release` for release.\n\nTo start the build:\n\n```bash\n/path/to/src $ cmake --build build\n```\n\nNote that we do not need to move into the `build` folder.\n\nTo build a release version:\n\n```bash\n/path/to/src $ cmake --build release --config Release\n```\n\nCheck [this link](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) for more information of the different configurations available.\n\n## Read The `.github/workflows/main.yml` File\n\nA lot of time and effort has been invested into this file. Incrementally, I figured out the things I needed to do in order to ensure that the commits that are pushed to this repository are checked automatically. This file is also very small (comapared to existing solutions) because of a few special features available due to the Github Actions API. Briefly the steps performed are:\n\n1. Installing CMake (using the [get-cmake action](https://github.com/marketplace/actions/get-cmake))\n2. Running CMake (Build file generation and the actual building in one step) using the [run-cmake action](https://github.com/marketplace/actions/run-cmake).\n3. Executing the binary that has been built.\n4. Performing this for both **Debug** and **Release**.\n5. Performing this for all the three operating systems: Ubuntu, MacOS and Windows (whatever the latest version happens to be).\n\nThere is also an option to skip the CI on a push if the commit message/body contains `[skip ci]`.\n\n## Features\n\n1. Provides a good starting point for new **C99** projects.\n2. Pragmatic directory structure is suggested with the existing code.\n3. Readable CMake configuration that can be customised easily.\n4. Inclusion of [µnit](https://nemequ.github.io/munit/) as the recommended unit-testing framework. It can be changed easily; just read the CMake and use the given directory structture to add your own library of choice.\n5. Integration with Github Actions. It ensures cross-platform builds and ensures that all unit-tests are successful (unless skipped).\n6. Inclusion of suggested badges for the project's README.\n\n## Reference\n\nAlmost all the material is derived from [An Introduction to Modern CMake](https://gitlab.com/CLIUtils/modern-cmake) by Henry Schreiner and others. Other sources will be mentioned as they pop up.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungrybluedev%2Fcmake-basic-c-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhungrybluedev%2Fcmake-basic-c-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungrybluedev%2Fcmake-basic-c-template/lists"}