Other CMake Tools

Let's learn about testing, packaging, and GUI in CMake.

We'll cover the following

CTest

Automated testing is very important in order to produce and maintain high-quality code. It is one of the available command-line tools, so let's briefly introduce it now.

CTest is about wrapping CMake in a higher layer of abstraction, where the building stage becomes just one of the stepping stones in the process of developing our software. Other tasks that CMake can do for us include:

  • Updating.

  • Running all kinds of tests.

  • Reporting the state of the project to the external dashboard.

  • Running scripts written in the CMake language.

More importantly, CTest standardizes running tests and reporting for solutions built with CMake. This means that as a user, we don't need to know which testing framework the project is using or how to run it. CTest provides a convenient façade to list, filter, shuffle, retry, and timebox test runs. Additionally, it can call CMake for us if a build is required.

The simplest way to run tests for a built project is to call ctest in the generated build tree:

Get hands-on with 1200+ tech skills courses.