CMake

Basically Makefiles are too ancient, so we created cmake instead.

CMake is an Open Source Software software for build automation, testing, packaging and installation of software itself. It generates system build files. It supports directory hierarchies and applications that depend on multiple libraries.

Why use CMake?

Theoretically, any C++ program can be compiled with g++. However, when the program gets bigger and bigger, a project may have many folders and source files.

In these cases, using CMake will make your life a lot easier that compiling all fines together by running a long tedious command every time.

CMake is widely used for the C and C++ languages, but it may be used to build source code of other languages too.

It creates a Makefile. So to compile, you usually do cmake . which calls the current directories CMakeLists.txt file. (But I use make -C qnx/build install) Then you run using make.

It will create an executable.

The cmake-make process

The cmake process handles the relationship between the project files, while the make process actually calls g++, or gcc or qcc to compile the program.

Documentation: https://cmake.org/cmake/help/latest/index.html

Some useful features to know:

  • install
  • set
  • add_libraries
  • target_link_libraries

Should probably find a tutorial and go through it.