Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commit cmake autogen makefiles/project files to git repo

If I have cmake build system that generate makefiles and project files, should I commit and push the makefiles to git repo? What are advantages and disadvantages of this?

If not, then after each pull and before build we need to generate all again using cmake?

Also, if I generated makefiles and build target, and then changed source file and then generated makefiles again (which is unnecessary), will cmake know what is already up to date? Or it will build all from scratch again?

like image 502
user28282 Avatar asked Sep 19 '25 16:09

user28282


1 Answers

In a CMake-based project, running cmake is not just a normal and expected part of the build process, but a required one. It prepares build supports and data (project file / makefile / etc.) that are customized to the build machine. Committing those generated artifacts helps no one, and it needlessly opens an avenue for confusion and user error (using the versions from the repository instead of generating new).

There is a school of thought that argues that nothing that can be (re)built automatically should be committed. I do not go so far myself, but certainly there's no point in committing anything that must be (re)built.

like image 135
John Bollinger Avatar answered Sep 21 '25 09:09

John Bollinger