# Introduction to cmake

raphaelmeyer
14K views

## Solution Exercise 4

Sample solution to the exercise:

# [project]/flux_capacitor/CMakeLists.txt

# ...


# [project]/flux_capacitor/tests/CMakeLists.txt

flux_capacitor.cc
flux.cc
capacitor.cc
)

PRIVATE
catchorg::catch2
time_machine::flux_capacitor
project::settings
)

target_include_directories(flux_capacitor-tests
PRIVATE ../src
)


CMake itselfs also provides an infrastructure to add tests to project. There are the commands add_test and enable_testing for adding tests to a project. And there is also a CMake test driver program called ctest.
Depending on your project structure, IDE integration and requirements when you want to run your test, the usage of ctest can be helpful.