Do not overwrite CUNIT_DISABLE_TESTS and CUNIT_DISABLE_EXAMPLES CMake variables if set by the user

Currently, in CMakeLists.txt the CUNIT_DISABLE_TESTS and CUNIT_DISABLE_EXAMPLES variables are set as CACHE INTERNAL. The CMake docs for set indicate that this will cause those variables to be set to the specified values, regardless of whether they had previously been set (either as cache variables or normal variables).

This doesn't seem like the intended behaviour: as far as I can tell there's no way for the user to change the value of these variables in a way that has the desired effect. Currently it appears that there's no way to prevent the Tests and Examples directories being brought in, which if CUnit is built as part of a larger build process means that CUnit's tests will end up in the set of tests run by CTest. The syntax being used to set the variables was also incorrect (FALSE was ending up as the description of the variable, not its value).

This change actually maintains the existing behaviour (if not previously set, these cache variables are set to empty values); however, it does this by attempting to set the variables to their existing value. If the user has already set this variable elsewhere, then their value will continue to be respected. If not, then it evaluates to an empty string - the same behaviour as before.

Merge request reports

Loading