summaryrefslogtreecommitdiffstats
path: root/Modules/FindMatlab.cmake
diff options
context:
space:
mode:
authorStefan Lietzau <lietzau@tesis.de>2019-06-18 16:21:56 (GMT)
committerStefan Lietzau <lietzau@tesis.de>2019-06-24 07:27:39 (GMT)
commit2454fe84f599abc55fe61eee45d22b45d6d2b7f2 (patch)
treefaefac4dea5eccf98134bbd098a062ef2a0dfdaf /Modules/FindMatlab.cmake
parent0a104224182565645b6bb8a1f81031c5afdc67ed (diff)
downloadCMake-2454fe84f599abc55fe61eee45d22b45d6d2b7f2.zip
CMake-2454fe84f599abc55fe61eee45d22b45d6d2b7f2.tar.gz
CMake-2454fe84f599abc55fe61eee45d22b45d6d2b7f2.tar.bz2
FindMatlab: Support EXACT versions
If an exact version is requested, don't pick the latest matlab version but the one matching the requested version. Fixes: #19155
Diffstat (limited to 'Modules/FindMatlab.cmake')
-rw-r--r--Modules/FindMatlab.cmake30
1 files changed, 22 insertions, 8 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 3547642..ce46870 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1442,14 +1442,28 @@ list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
set(Matlab_VERSION_STRING "NOTFOUND")
set(Matlab_Or_MCR "UNKNOWN")
if(_numbers_of_matlab_roots GREATER 0)
- list(GET _matlab_possible_roots 0 Matlab_Or_MCR)
- list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING)
- list(GET _matlab_possible_roots 2 Matlab_ROOT_DIR)
-
- # adding a warning in case of ambiguity
- if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG)
- message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
- " If this is not the desired behaviour, provide the -DMatlab_ROOT_DIR=... on the command line")
+ if(Matlab_FIND_VERSION_EXACT)
+ list(FIND _matlab_possible_roots ${Matlab_FIND_VERSION} _list_index)
+ if(_list_index LESS 0)
+ set(_list_index 1)
+ endif()
+
+ math(EXPR _matlab_or_mcr_index "${_list_index} - 1")
+ math(EXPR _matlab_root_dir_index "${_list_index} + 1")
+
+ list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR)
+ list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING)
+ list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR)
+ else()
+ list(GET _matlab_possible_roots 0 Matlab_Or_MCR)
+ list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING)
+ list(GET _matlab_possible_roots 2 Matlab_ROOT_DIR)
+
+ # adding a warning in case of ambiguity
+ if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
+ " If this is not the desired behaviour, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line")
+ endif()
endif()
endif()