summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorscivision <scivision@users.noreply.github.com>2024-01-16 00:20:44 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-16 16:37:43 (GMT)
commit42fbe01ebaa3802a99fe2a03c9b98b17d24d0704 (patch)
treedcea9972cf83e22174398ef723fd80ea755cb369 /Modules
parentc608adc2366e1f3a9b44cb9346222852acc8de70 (diff)
downloadCMake-42fbe01ebaa3802a99fe2a03c9b98b17d24d0704.zip
CMake-42fbe01ebaa3802a99fe2a03c9b98b17d24d0704.tar.gz
CMake-42fbe01ebaa3802a99fe2a03c9b98b17d24d0704.tar.bz2
FindMatlab: Accept long version in matlab_get_release_name_from_version
Make this work: matlab_get_release_name_from_version(${Matlab_VERSION}) which the user would expect. While at it, simplify this function code.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindMatlab.cmake24
1 files changed, 7 insertions, 17 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 54a6d4c..24703a3 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -378,31 +378,21 @@ endmacro()
Returns the release name from the version of Matlab
#]=======================================================================]
-macro(matlab_get_release_name_from_version version release_name)
+function(matlab_get_release_name_from_version version release_name)
# only the major.minor version is used
- if(version MATCHES "([0-9]+\\.[0-9]+)")
- set(short_version ${CMAKE_MATCH_1})
- else()
- set(short_version ${version})
- endif()
+ string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" version "${version}")
- set(${release_name} "")
foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
- string(REGEX MATCHALL "(.+)=${short_version}" _matched ${_var})
- if(NOT _matched STREQUAL "")
- set(${release_name} ${CMAKE_MATCH_1})
- break()
+ if(_var MATCHES "(.+)=${version}")
+ set(${release_name} ${CMAKE_MATCH_1} PARENT_SCOPE)
+ return()
endif()
endforeach()
- unset(_var)
- unset(_matched)
- if(${release_name} STREQUAL "")
- message(WARNING "[MATLAB] The version ${short_version} is not registered")
- endif()
+ message(WARNING "[MATLAB] The version ${version} is not registered")
-endmacro()
+endfunction()
# extracts all the supported release names (R2022b...) of Matlab