FindMatlab fails to select correct (minimum) version
So i am currently trying to use Matlab 2021b prerelease due to the hdf5 update to 1.10.7. The problem is that if multiple versions are installed FindMatlab does not select the correct version (unless probably EXACT is specified)
the find_package call is:
set(MATLAB_ADDITIONAL_VERSIONS "2021b=9.11") # needs to be added into the module anways
set(MATLAB_FIND_DEBUG ON)
find_package(Matlab 9.11 REQUIRED COMPONENTS MAT_LIBRARY)
CMake Output indicates it can find 2021b:
[cmake] -- [MATLAB] Matlab root folders are MATLAB;9.8;C:/Program Files/MATLAB/R2020a;MATLAB;9.11;C:/Program Files/MATLAB/R2021b
but it selects the first of the list indicated by:
[cmake] CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/FindMatlab.cmake:1554 (message):
[cmake] [MATLAB] Found several distributions of Matlab. Setting the current
[cmake] version to 9.8 (located C:/Program Files/MATLAB/R2020a). If this is not
[cmake] the desired behaviour, use the EXACT keyword or provide the
[cmake] -DMatlab_ROOT_DIR=... on the command line
which of course errors at the end as:
[cmake] -- [MATLAB] Current version is 9.8 located C:/Program Files/MATLAB/R2020a
[cmake] -- [MATLAB] Determining mex files extensions from 'C:/Program Files/MATLAB/R2020a/bin' with program 'C:/Program Files/MATLAB/R2020a/bin/mexext.bat'
[cmake] -- [MATLAB] 'C:/Program Files/MATLAB/R2020a/bin/mexext.bat' : determined extension 'mexw64' and error string is ''
[cmake] -- [MATLAB] [DEBUG]_matlab_lib_prefix_for_search = lib | _matlab_lib_dir_for_search = C:/Program Files/MATLAB/R2020a/extern/lib/win64/microsoft
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
[cmake] Could NOT find Matlab: Found unsuitable version "9.8", but required is at
[cmake] least "9.11" (found C:/Program Files/MATLAB/R2020a/extern/include, found
[cmake] components: MAT_LIBRARY)