소스 검색

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.
Mihai Moldovan 3 년 전
부모
커밋
6b6bc7791d
1개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 12 1
      Modules/FindRuby.cmake

+ 12 - 1
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)