CMake init / template projects

I know that CMake has a certain scope on what you want to do and what you don’t want to do - Have you considered shipping functionality like cmake-init (GitHub - friendlyanon/cmake-init: The missing CMake project initializer)?

I think it could greatly improve usability and making sure that new projects use the correct and current best practices.

1 Like

Just to clarify - I’m not asking for third party tool support such as github actions / clang-tidy etc. Just support for generating a current best practice cmake project.

I believe there is a getting started project with best practices which serves as an introduction to CMake. This should make a generator somewhat redundant.

Note that the project from your link is for C, CPP projects specifically. There is hardly anything that serves as a generic template, starting from the minimum CMake version to everything else.

Thanks for your answer.
Ill try to explain why I still believe it would be useful.

The existence of both a project initializer and documentation does not mean either is redundant. The best practices are scattered over many pages and never show the full picture. This makes it difficult to completely grasp how one is meant to setup a project, and furthermore many may choose to skip a bunch of steps because they just managed to get something half working.

It also encourages some bad practices, such as SET(CMAKE_CXX_STANDARD), and storing .h and .cpp files in the root folder. This is completely understandable because the focus of a tutorial is explaining concepts in a simple manner, but it does not make sense when you are creating a project initializer.

Your second argument concerning language could simply be covered by making it an argument: ala cmake init --language c++ or via an interactive cli - or for starters just say its experimental and for c++ only.

Overall I know that people are having a hard time learning how to write cmake, and I believe there exists more half-correct projects out there than proper ones. The result of this is a torn ecosystem which makes it more difficult for other tools, such as dependency managers (GitHub - cpm-cmake/CPM.cmake: 📦 CMake's missing package manager. A small CMake script for setup-fre) to consume cmake libraries.

Is there any doubt as to what this is bringing to the table in addition to “best practices”?