FindMatlab: Changing the Matlab version requires a clean cache
This is not a regression, but more a feature request I would like to put into consideration.
find_package(Matlab 9.9 EXACT REQUIRED)
correctly locates an installed version of Matlab and sets Matlab_ROOT_DIR
in the cache.
Subsequent configure runs determine that Matlab_ROOT_DIR
is set and do not look for other Matlab installations, as if the user explicitly specified that version.
Thus, changing the required Matlab version, for example to find_package(Matlab 9.10 EXACT REQUIRED)
, might fail if the previously discovered version does not fulfill the newly required version.
Currently, there is not difference between a user-specified Matlab_ROOT_DIR
and a cached Matlab_ROOT_DIR
from the previous configure run.
Unfortunately, this is documented behavior (https://cmake.org/cmake/help/latest/module/FindMatlab.html): FindMatlab
uses Matlab_ROOT_DIR
to look for a Matlab installation and sets Matlab_ROOT_DIR
in the cache when a Matlab installation is found.
Therefore, changing something here might break existing code.
How to other Find*
modules handle this?
Is it common practice to require a clean cache to change the desired version?
Would it be acceptable to change this behavior for 3.29?
For example, by not setting Matlab_ROOT_DIR
to the cache, but setting it as a non-cache variable (with directory scope I guess).