1

I am currently working on a project which requires me to learn about CMake and GMake. I read about them but still don't get their applications.

Can someone provide a few examples of how CMake and GMake are used in software development?

Thank You.

Naman Bansal
  • 191
  • 2
  • 13

2 Answers2

7

make or gmake uses Makefiles to describe how to build your code. A Makefile contains targets and recipes. A target can be an object file or executable and the recipe is how to produce that target.

cmake is a higher level language with the same purpose but with a higher level of abstraction. With cmake you can generate ordinary Makefiles or files for other build systems, such as Ninja etc.

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • So every `Makefile` written with `gmake` can be executed with `cmake` but not viceversa? – baggiponte Jul 13 '22 at 15:17
  • 2
    @baggiponte `Makefile`s are written _for_ `make`/`gmake` (which means that they can be parsed by `make`/`gmake`). `cmake` parses `CMakeLists.txt` files and _generates_ `Makefile`s (or `Ninja` files for example) that can then be parsed by `make`/`gmake` (or `Ninja`). – Ted Lyngmo Jul 13 '22 at 15:20
3

CMake is used to generate a project, it does not compile nor create object files, but generates files that will be used by other softwares such as GNU make (GMake). It uses CMakeLists.txt files for configuration.

GMake is the name for GNU make which is basically the make command on Linux (https://linux.die.net/man/1/gmake). It uses Makefile files for configuration.

Nathanael Demacon
  • 1,169
  • 7
  • 19