{"id":13603129,"url":"https://github.com/friendlyanon/cmake-init","last_synced_at":"2025-05-13T20:15:21.748Z","repository":{"id":37555171,"uuid":"356934001","full_name":"friendlyanon/cmake-init","owner":"friendlyanon","description":"The missing CMake project initializer","archived":false,"fork":false,"pushed_at":"2025-02-18T18:59:33.000Z","size":2922,"stargazers_count":2296,"open_issues_count":24,"forks_count":88,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-05-13T01:42:48.201Z","etag":null,"topics":["boilerplate","c","ci","clang-format","clang-tidy","cmake","codespell","conan","coverage","cpp","cppcheck","executable","header-only","python","scaffolding","shared-library","static-analysis","static-library","testing","vcpkg"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friendlyanon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2021-04-11T17:29:21.000Z","updated_at":"2025-05-12T19:36:18.000Z","dependencies_parsed_at":"2023-12-03T19:31:36.388Z","dependency_job_id":"0bc2b018-6a49-49c6-9dbf-4e9beb223c36","html_url":"https://github.com/friendlyanon/cmake-init","commit_stats":{"total_commits":477,"total_committers":8,"mean_commits":59.625,"dds":"0.014675052410901501","last_synced_commit":"38a761cb4253a3a50c330c503c6e8a3ec39f80ea"},"previous_names":[],"tags_count":90,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friendlyanon%2Fcmake-init/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friendlyanon","download_url":"https://codeload.github.com/friendlyanon/cmake-init/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856600,"owners_count":21974574,"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":["boilerplate","c","ci","clang-format","clang-tidy","cmake","codespell","conan","coverage","cpp","cppcheck","executable","header-only","python","scaffolding","shared-library","static-analysis","static-library","testing","vcpkg"],"created_at":"2024-08-01T18:01:52.440Z","updated_at":"2025-05-13T20:15:21.727Z","avatar_url":"https://github.com/friendlyanon.png","language":"CMake","readme":"# `cmake-init` - The missing CMake project initializer\n\n`cmake-init` is an opinionated CMake project initializer that generates CMake\nprojects which are FetchContent ready, separate consumer and developer targets,\nprovide install rules with proper relocatable CMake packages and use modern\nCMake (3.14+).\n\nPlease see the [wiki][17] for example outputs of cmake-init and other pragmatic\nexamples of functionality implemented for CMake, like package managers, fuzz\ntesting, superbuilds, etc.\n\n![Example GIF of cmake-init in action](assets/example.gif)\n\n\u003cdetails\u003e\n\n\u003csummary\u003eVSCode integration with minimal configuration using presets:\u003c/summary\u003e\n\n![Configuring the project in VSCode](assets/vscode-config.png)\n\n![Building the project in VSCode](assets/vscode-build.png)\n\n![Testing the project in VSCode](assets/vscode-test.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eCLion integration with minimal configuration using presets:\u003c/summary\u003e\n\n![Selecting the dev preset in CLion](assets/clion-preset.png)\n\n![Testing the project in CLion](assets/clion-test.png)\n\n\u003c/details\u003e\n\nIf you wish to contact me for anything CMake related, then you may find me in\nthe `#cmake` channel of [the C++ Slack][26]. If what you wish to know is\ncmake-init specific, then you may also ask questions in this repository's\n[Discussions][27].\n\n## Goals\n\n* Be simple to use  \n  The script allows you to just mash enter to get you a correctly set up\n  project for an executable. You want a header-only library? Choose `h` when\n  prompted. Static/shared library? Just choose `s` when prompted. Simple\n  **and** correct!\n* Create [`FetchContent`][1] ready projects  \n  This is important, because in the near feature this might allow CMake to\n  consume other projects in a trivial fashion similar to other languages, e.g.\n  in JavaScript's case (npm).\n* Cleanly separate developer and consumer targets  \n  This ties into the previous point as well, but developers and consumers of a\n  project have different needs, and separating targets achieves that goal. A\n  developer should be able to run tests, add warning flags, run benchmarks,\n  etc., while a consumer, such as a package maintainer, generally only wants to\n  build the library or the executable itself, without having to patch around in\n  the CMake scripts. Show some love to your package maintainers!\n* Use modern CMake (3.14+)  \n  There are too many outdated and plain wrong examples on the internet, it's\n  time to change that.\n* Make usage of tools easy  \n  Code coverage (gcov), code linting and formatting (clang-format), static\n  analysis (clang-tidy) and dynamic analysis (sanitizers, valgrind) are all\n  very helpful ways to guide the developer in creating better software, so they\n  should be easy to use.\n\n### Relevant conference talks\n\n* [Kenneth Hoste - How To Make Package Managers Cry\n](https://www.youtube.com/watch?v=NSemlYagjIU)\n* [Robert Schumacher - Don't package your libraries, write packagable\nlibraries! (Part 1)](https://www.youtube.com/watch?v=sBP17HQAQjk)\n* [Robert Schumacher - Don't package your libraries, write packagable\nlibraries! (Part 2)](https://www.youtube.com/watch?v=_5weX5mx8hc)\n* [Craig Scott - Deep CMake for Library Authors\n](https://www.youtube.com/watch?v=m0DwB4OvDXk)\n\n## Non-goals\n\n* Cover every possible project structure  \n  Doing this is pointless as an init script, because there are far too many\n  ways people have been building software, and if you have special needs, you\n  ought to already know CMake and you can set the project up yourself.\n* Generate files and show tips for websites other than GitHub  \n  While I understand the people who are against GitHub (and by proxy\n  Microsoft), it's by far the most used website of its kind, the files and\n  messages specific to it are small in number, and they are easily adapted for\n  any other service.\n\n## Install\n\nMake sure you have these programs installed:\n\n* Python 3.8 or newer\n* CMake 3.20 or newer (3.21 or newer for C17 or newer projects)\n* git\n* [clang-tidy 18](#clang-tidy) (optional)\n* [cppcheck](#cppcheck) (optional)\n* [Doxygen \u003c 1.9](#doxygen) (optional)\n* [LCOV](#lcov) (optional)\n* [clang-format 18](#clang-format) (optional)\n* [codespell](#codespell) (optional)\n* [Package managers](#package-managers): Conan or vcpkg (optional)\n\n---\n**NOTE**\n\nSome of these tools can be used on Windows as well if you want to use Visual\nStudio, but you have to install these addins:\n\n- https://clangpowertools.com/\n- https://github.com/VioletGiraffe/cppcheck-vs-addin\n\n---\n\nThis package is available for download from [PyPI][15]. You can install this\npackage using `pip`:\n\n```bash\npip install cmake-init\n```\n\n### clang-tidy\n\n[clang-tidy][5] is a static analysis tool that helps you spot logical errors in\nyour code before it is compiled. This script gives you the option to inherit\nthe `clang-tidy` preset in your `dev` preset, enabling the CMake integration\nfor this tool.\n\nCI will always run clang-tidy for you, so it is entirely optional to install\nand use it locally, but it is recommended.\n\n**For Windows users**, if you wish to use clang-tidy, then you must install\n[Ninja][6] and set the `generator` field in your `dev` preset to `Ninja`. The\nreason for this is that only [Makefiles and Ninja][7] are supported with CMake\nfor use with clang-tidy. For other generators, this feature is a no-op.\n\n### cppcheck\n\n[cppcheck][8] is a static analysis tool similar to clang-tidy, however the\noverlap in what they detect is minimal, so it's beneficial to use both of them.\nThis script gives you the option to inherit the `cppcheck` preset in your `dev`\npreset, enabling the CMake integration for this tool.\n\nCI will always run cppcheck for you, so it is entirely optional to install and\nuse it locally, but it is recommended.\n\n**For Windows users**, if you wish to use cppcheck, then you must install\n[Ninja][6] and set the `generator` field in your `dev` preset to `Ninja`. The\nreason for this is that only [Makefiles and Ninja][9] are supported with CMake\nfor use with cppcheck. For other generators, this feature is a no-op.\n\n### Doxygen\n\n[Doxygen][10] is a tool to generate documentation from annotated source code.\nIn conjunction with it, [m.css][11] is used for presenting the generated\ndocumentation.\n\nThe generated projects will have a `docs` target in developer mode, which can\nbe used to build the documentation into the `\u003cbinary-dir\u003e/docs/html` directory.\n\nAfter Doxygen is installed, please make sure the `doxygen` executable exists in\nthe `PATH`, otherwise you might get confusing error messages.\n\nThis documentation can be deployed to GitHub Pages using the `docs` job in the\ngenerated CI workflow. Follow the comments left in the job to enable this.\n\n**NOTE**: m.css does not work with Doxygen \u003e= 1.9. You can install 1.8.20 to\nuse the `docs` target. See issues [#41][18] and [#48][19].\n\n### LCOV\n\n[LCOV][12] is a tool to process coverage info generated by executables that\nwere instrumented with GCC's `gcov`. This coverage info can be used to see what\nparts of the program were executed.\n\nThe generated projects will have a `coverage` target in developer mode if the\n`ENABLE_COVERAGE` variable is enabled. The reason why a separate target is used\ninstead of CTest's built-in `coverage` step is because it lacks necessary\ncustomization. This target should be run after the tests and by default it will\ngenerate a report at `\u003cbinary-dir\u003e/coverage.info` and an HTML report at the\n`\u003cbinary-dir\u003e/coverage_html` directory.\n\n**For Windows users**, you may use a similar tool called [OpenCppCoverage][16],\nfor which there is an example script in the generated `cmake` directory. This\nscript is left as an example, because the Linux VM launches and runs faster in\nGitHub Actions and so it is used for coverage submission.\n\n### clang-format\n\n[clang-format][13] is part of the LLVM tool suite similar to\n[clang-tidy](#clang-tidy). It's a code linter and code formatter, which can be\nused to enforce style guides.\n\nTwo targets are made available to check and fix code in developer mode using\nthe `format-check` and `format-fix` targets respectively.\n\n**NOTE**: the project generates files that are formatted according to\nclang-format 18. Newer or older versions may format the project differently.\n\n### codespell\n\n[codespell][14] is a tool to find and fix spelling errors mainly in source\ncode.\n\nTwo targets are made available to check and fix spelling errors in developer\nmode using the `spell-check` and `spell-fix` targets respectively.\n\n### Package managers\n\nThe `-p` flag can be used to select a package manager for the project.\nArguments for the flag can be:\n\n* `none`: no package manager integration (default)\n* `conan`: [Conan][20] integration\n* `vcpkg`: [vcpkg][21] integration\n\nWhen using a package manager, the following packages are used in the generated\nproject:\n\n* [fmt][22] for C++, [json-c][23] and [hedley][25] (exe only) for C projects\n* [Catch2][24] as a dev dependency for C++ and C projects\n\nMake sure to read the generated HACKING document to see what needs to be done\nto fetch dependencies.\n\n## Usage\n\n* `cmake-init [--c] \u003cpath\u003e`  \n  This command will create a CMake project at the provided location and\n  according to the answers given to the prompts. You may pass the `-s`, `-e` or\n  `-h` flags after to quickly create a shared library, executable or a header\n  only library respectively. The `--c` switch will set the generated project's\n  type to C instead of C++.\n* `cmake-init --help`  \n  Shows the help screen for more flags and switches.\n\n## Licensing\n\n[![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)][2]  \n\n`cmake-init` is Free Software: You can use, study, share and improve it at your\nwill. Specifically you can redistribute and/or modify it under the terms of the\n[GNU General Public License][3] as published by the Free Software Foundation,\neither version 3 of the License, or (at your option) any later version.\n\nThe contents of the directory `cmake-init/templates` are licensed using the\n[Unlicense][28] license. See the license in that directory for further details.\n\n[1]: https://cmake.org/cmake/help/latest/module/FetchContent.html\n[2]: http://www.gnu.org/licenses/gpl-3.0.en.html\n[3]: https://www.gnu.org/licenses/gpl.html\n[4]: https://github.com/friendlyanon/cmake-init/releases\n[5]: https://clang.llvm.org/extra/clang-tidy/\n[6]: https://github.com/ninja-build/ninja\n[7]: https://cmake.org/cmake/help/latest/prop_tgt/LANG_CLANG_TIDY.html\n[8]: http://cppcheck.sourceforge.net/\n[9]: https://cmake.org/cmake/help/latest/prop_tgt/LANG_CPPCHECK.html\n[10]: https://www.doxygen.nl/\n[11]: https://mcss.mosra.cz/\n[12]: http://ltp.sourceforge.net/coverage/lcov.php\n[13]: https://clang.llvm.org/docs/ClangFormat.html\n[14]: https://github.com/codespell-project/codespell\n[15]: https://pypi.org/project/cmake-init/\n[16]: https://github.com/OpenCppCoverage/OpenCppCoverage\n[17]: https://github.com/friendlyanon/cmake-init/wiki/Examples\n[18]: https://github.com/friendlyanon/cmake-init/issues/41\n[19]: https://github.com/friendlyanon/cmake-init/issues/48\n[20]: https://conan.io/\n[21]: https://github.com/microsoft/vcpkg\n[22]: https://github.com/fmtlib/fmt\n[23]: https://github.com/json-c/json-c\n[24]: https://github.com/catchorg/Catch2\n[25]: https://github.com/nemequ/hedley\n[26]: https://cppalliance.org/slack/\n[27]: https://github.com/friendlyanon/cmake-init/discussions\n[28]: https://unlicense.org/\n","funding_links":[],"categories":["CMake","c"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendlyanon%2Fcmake-init","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriendlyanon%2Fcmake-init","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriendlyanon%2Fcmake-init/lists"}