summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-07 13:48:17 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-07 13:48:17 (GMT)
commit48b33b0633f61d453146e2ce4813b9731c6f0836 (patch)
treec7c048ad19336aff58da811b339a7c51217b2632
parentf76bcee9a6a95b566e36b533a5fa45b496eb456b (diff)
parent29768b03eabcff13b332497caf2fb0e1c1ca717b (diff)
downloadCMake-48b33b0633f61d453146e2ce4813b9731c6f0836.zip
CMake-48b33b0633f61d453146e2ce4813b9731c6f0836.tar.gz
CMake-48b33b0633f61d453146e2ce4813b9731c6f0836.tar.bz2
Merge topic 'FindMatlab-fix-empty-list-index'
29768b03 FindMatlab: Avoid indexing an empty list of versions
-rw-r--r--Modules/FindMatlab.cmake8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 9f96fe6..b501599 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1030,13 +1030,17 @@ function(_Matlab_get_version_from_root matlab_root matlab_known_version matlab_f
set(matlab_list_of_all_versions)
matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions)
- list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
+ list(LENGTH matlab_list_of_all_versions list_of_all_versions_length)
+ if(${list_of_all_versions_length} GREATER 0)
+ list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
+ else()
+ set(_matlab_version_tmp "")
+ endif()
# set the version into the cache
set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
# warning, just in case several versions found (should not happen)
- list(LENGTH matlab_list_of_all_versions list_of_all_versions_length)
if((${list_of_all_versions_length} GREATER 1) AND MATLAB_FIND_DEBUG)
message(WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})")
endif()