Skip to content

Add option to enable/disable tests

Simon Praetorius requested to merge feature/superbuild-deactivate-tests into master

Summary

This MR adds an option DUNE_ENABLE_TESTING that is turned ON by default in classical builds, but allows to be set to OFF, if a user does not want to include tests in the build. The variable can be used to conditionally add the test/ subdirectory to CMake. This option does not change anything in the current default behavior, but it changes the behavior if a dune module is consumed by another project. If the dune project is not a top-level project, the DUNE_ENABLE_TESTING option is set to OFF.

Motivation

When a dune module is consumed as an external dependency in another project, that just want to use some functionality from a module, it is not always necessary to run all the tests of all the module-dependency chain. In Craig Scotts "Professional CMake" he writes the recommendation "Tests are much less likely to be of interest to the developer when a project is not the top level of the build, so they should be disabled by default when they are not the top level.". This does not mean that tests are eliminated. They can still be reactivated by setting the option DUNE_ENABLE_TESTING:BOOL=ON.

Another motivation comes from the superbuild mode. When several modules are combined, it is very likely that there is a name clash. Several modules might define the same test targets. The leads to a hard CMake error making it impossible to use the given module configuration with a CMake superbuild. See the issue #377.

Every dune module can decide whether to use this option to conditionally add test or example subdirectories. Nothing is enforced by this MR.

Edited by Simon Praetorius

Merge request reports

Loading