FindRuby: Update to handle RVM environments
EDIT: This merge request originally made changes to support ruby 2.7 and RVM. The former parts have been moved to !4463 (merged), !4476 (merged), and !4481 (merged).
Original Description
Fixes #20370 (closed) (hopefully). This is my first code contribution to the CMake project so I assume there's a bunch of stuff that could use adjustments.
Focus points:
- Result variables have historically been all upper case, that is RUBY_xxx instead of Ruby_xxx like other FindXXX.cmake modules. Eg it returns RUBY_EXECUTABLE instead of Ruby_EXECUTABLE. I didn't want to break backward compat so I didn't change that.
- I tried to add thorough tests (and they helped catch a bunch of issues), but they are pretty specific to my own machine, due to fact that I test based on my system version and the RVM versions I have installed... I know nothing about your CI setup, so not in a position to make that better right now.
Side Notes:
- I realized at one point that I was never entering a
WHILE(TRUE)
block. I found #18141 (closed) which helped me set the policy. But I had copied that from FindPython/Support.cmake, so not sure if it's intended over there... https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindPython/Support.cmake#L976
Topic-rename: FindRuby-rvm
Edited by Brad King