Enable opting-out of tests
include(CTest)
offers a default-enabled option()
called BUILD_TESTING
, to let the user control if they want to build the project's tests. Since that include is already in the top-level CMakeLists.txt, we should only add the tests subdirectory if this option is enabled.
Additionally, the "Mastering CMake" tutorial says
The
CTest
module will automatically callenable_testing()
, so we can remove it from our CMake files.
So we shall do just that.