-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Minimal CMake
By :
Now that we understand what CTest offers, let’s look at a concrete example of adding unit tests to a couple of our existing libraries, we’ll start with mc-array. Just to note at the outset, there are a few different ways we can choose to structure our project to support testing. One choice is to create a subdirectory in the root of the project that is decoupled from our root-level CMakeLists.txt file:
. ├── CMakeLists.txt ├── ... └── tests ├── CMakeLists.txt └── tests.cpp
With this setup, users are required to navigate to the subfolder and run the standard CMake configure and build commands. The test project would link against the top-level application, likely relying on FetchContent with a relative path using SOURCE_DIR.
Another option is to keep the preceding layout but use add_subdirectory...