CMake is a build automation and testing platform for portably building C/C++ software. It’s the standard way to build any software based on C/C++, especially because it can hook up to native compilation tools (i.e., Makefiles on Linux systems).

CMake relies on a custom scripting language (like many other build automation tools). The core part of any CMake project is the CMakeLists.txt file. This specifies the parameters of the project.

Build file

Some key characteristics we should define:

  • cmake_minimum_required(VERSION x.xx...x.xx) — is a required part of the file. We should ideally be using newer versions of CMake if possible. Starting in CMake 3.12, we’re allowed to use a range of values. Newer versions should use a range of values.
  • project() identifies specific project parameters.
project(MyProject VERSION 1.0
                  DESCRIPTION "Very nice project"
                  LANGUAGES CXX)

Some additional commands we can use:

  • set(VARNAME "value") — sets a local variable with identifier VARNAME.

Resources

Addendums

If it’s throwing a Detecting C compiler ABI info - failed error, try: