Browse Source

FindMatlab: Sort available Matlab versions using natural comparison.

On Windows, when FindMatlab.cmake searches the registry for installed Matlab versions, it sorts these versions alphabetically.
Since Matlab 2021a (version 9.10) came out this became a problem as now version 9.10 is placed after 9.1 instead of after a higher version less than 9.10.
The result is that FindMatlab doesn't return the highest version by default.
This fix uses the natural sort comparison which was introduced in CMake 3.18.
Vincent Newsum 4 years ago
parent
commit
2f43ba5073
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Modules/FindMatlab.cmake

+ 2 - 2
Modules/FindMatlab.cmake

@@ -477,7 +477,7 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio
 
   if(matlabs_from_registry)
     list(REMOVE_DUPLICATES matlabs_from_registry)
-    list(SORT matlabs_from_registry)
+    list(SORT matlabs_from_registry COMPARE NATURAL)
     list(REVERSE matlabs_from_registry)
   endif()
 
@@ -521,7 +521,7 @@ macro(extract_matlab_versions_from_registry_brute_force matlab_versions)
   # we order from more recent to older
   if(matlab_supported_versions)
     list(REMOVE_DUPLICATES matlab_supported_versions)
-    list(SORT matlab_supported_versions)
+    list(SORT matlab_supported_versions COMPARE NATURAL)
     list(REVERSE matlab_supported_versions)
   endif()