summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2022-01-31 04:57:39 (GMT)
committerMihai Moldovan <ionic@ionic.de>2022-01-31 04:57:42 (GMT)
commit6b6bc7791d21f45a930b04b8e88102ee7fafb6ad (patch)
treedd4e79da1a36de39de37b414478e25b74e0f965d
parent42d99a248ebd3a57d6962eed6d19559334b9a376 (diff)
downloadCMake-6b6bc7791d21f45a930b04b8e88102ee7fafb6ad.zip
CMake-6b6bc7791d21f45a930b04b8e88102ee7fafb6ad.tar.gz
CMake-6b6bc7791d21f45a930b04b8e88102ee7fafb6ad.tar.bz2
FindRuby: evict non-matching binaries and keep scanning.
The possible executable names list always starts with a plain "ruby" binary, which is scanned for first. If that does exist (which satisfies find_program), but doesn't match the requested version, the executable will be dismissed by _RUBY_VALIDATE_INTERPRETER (which is sane), but searching also stops. Fix that by keeping the search going, removing items from the list as we go, until find_program returns a path that _RUBY_VALIDATE_INTERPRETER is happy with or the list is empty.
-rw-r--r--Modules/FindRuby.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake
index ec05cea..a80758d 100644
--- a/Modules/FindRuby.cmake
+++ b/Modules/FindRuby.cmake
@@ -266,9 +266,20 @@ while(1)
_RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION})
if (Ruby_EXECUTABLE)
break()
+ else()
+ # Remove first entry from names list.
+ LIST(REMOVE_AT _Ruby_POSSIBLE_EXECUTABLE_NAMES 0)
+
+ # If the list is now empty, abort.
+ if (NOT _Ruby_POSSIBLE_EXECUTABLE_NAMES)
+ break()
+ else()
+ # Otherwise, continue with the remaining list. Make sure that we clear
+ # the cached variable.
+ unset(Ruby_EXECUTABLE CACHE)
+ endif()
endif()
- break()
endwhile()
if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR)