From d7b73f14c23bd53051503da460642447bf94b0b6 Mon Sep 17 00:00:00 2001 From: scivision Date: Thu, 14 Sep 2023 17:04:10 -0400 Subject: FindMatlab: retrieve full major.minor.patch.tweak --- Modules/FindMatlab.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 7b15897..a3e966b 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -380,9 +380,17 @@ endmacro() #]=======================================================================] macro(matlab_get_release_name_from_version version release_name) + # only the major.minor version is used + string(REGEX MATCH "([0-9]+\\.[0-9]+)" _match ${version}) + if(CMAKE_MATCH_1) + set(short_version ${CMAKE_MATCH_1}) + else() + set(short_version ${version}) + endif() + set(${release_name} "") foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING) - string(REGEX MATCHALL "(.+)=${version}" _matched ${_var}) + string(REGEX MATCHALL "(.+)=${short_version}" _matched ${_var}) if(NOT _matched STREQUAL "") set(${release_name} ${CMAKE_MATCH_1}) break() @@ -392,7 +400,7 @@ macro(matlab_get_release_name_from_version version release_name) unset(_var) unset(_matched) if(${release_name} STREQUAL "") - message(WARNING "[MATLAB] The version ${version} is not registered") + message(WARNING "[MATLAB] The version ${short_version} is not registered") endif() endmacro() @@ -1396,12 +1404,12 @@ function(_Matlab_VersionInfoXML) if(versioninfo_string) # parses "23.2.0.2365128" - string(REGEX MATCH "(.*)" + string(REGEX MATCH "([0-9]+\\.[0-9]+\\.?[0-9]*\\.?[0-9]*)" version_reg_match ${versioninfo_string} ) - if(CMAKE_MATCH_1 MATCHES "(([0-9]+)\\.([0-9]+))[\\.0-9]*") + if(CMAKE_MATCH_1) set(_matlab_version_tmp "${CMAKE_MATCH_1}") endif() endif() -- cgit v0.12