FindMatlab: proposed 100x-1000x speedup and reliability improvement
Proposed FindMatlab changes in !8760 (merged) prefer to parse VersionInfo.xml instead of running Matlab. On Windows, the registry is used in like fashion to avoid running Matlab just to get the version. This MR benefits non-Windows Matlab users. I checked back to Matlab R2016a that VersionInfo.xml exists. I'm not sure what the first Matlab version that had VersionInfo.xml was--but the MR falls back to running Matlab as before for ancient Matlab.
On some network-installed drives with lots of Matlab toolboxes (as typical on HPC), FindMatlab can take several seconds, on some HPC up to 45 seconds just to get the Matlab version.
On a fast local RAID drive on a powerful workstation, doing matlab -batch -nojvm version
takes just under 3 seconds, which is about 99% of the time required to configure a minimal CMakeLists.txt.
With the MR changes, FindMatlab takes about 30 milliseconds total, for about 100x (local install) - 1000x (network install) FindMatlab speedup and reliability enhancement by not running Matlab.
cmake_minimum_required(VERSION 3.12)
project(foo LANGUAGES NONE)
find_package(Matlab COMPONENTS MAIN_PROGRAM REQUIRED)