Getting ready

We will start with the example presented in Chapter 4, Creating and Running Tests, Recipe 2, Defining a unit test using the Catch2 library. The main.cpp, sum_integers.cpp, and sum_integers.hpp files are unchanged and can be used to compute the sum of integers provided as command line arguments. The source code for the unit tests (test.cpp) is used unchanged, as well. We also require the Catch2 header file, catch.hpp. In contrast to Chapter 4, Creating and Running Tests, Recipe 2, Defining a unit test using the Catch2 library, we will structure the source files into subdirectories and form the following file tree (we will discuss the CMake code later):

.├── CMakeLists.txt├── src│   ├── CMakeLists.txt│   ├── main.cpp│ ├── sum_integers.cpp ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.