FindRuby¶
This module determines if Ruby is installed and finds the locations of its include files and libraries. Ruby 1.8 through 3.4 are supported.
The minimum required version of Ruby can be specified using the standard syntax, e.g.
find_package(Ruby 3.2.6 EXACT REQUIRED)
# OR
find_package(Ruby 3.2)
Virtual environments, such as RVM or RBENV, are supported.
Result Variables¶
This module will set the following variables in your project:
Ruby_FOUNDset to true if ruby was found successfully
Ruby_EXECUTABLEfull path to the ruby binary
Ruby_INCLUDE_DIRSinclude dirs to be used when using the ruby library
Ruby_LIBRARIESAdded in version 3.18: libraries needed to use ruby from C.
Ruby_VERSIONthe version of ruby which was found, e.g. "3.2.6"
Ruby_VERSION_MAJORRuby major version.
Ruby_VERSION_MINORRuby minor version.
Ruby_VERSION_PATCHRuby patch version.
Changed in version 3.18: Previous versions of CMake used the RUBY_ prefix for all variables.
Deprecated since version 4.0: The following variables are deprecated. See policy CMP0185.
RUBY_EXECUTABLEsame as
Ruby_EXECUTABLE.RUBY_INCLUDE_DIRSsame as
Ruby_INCLUDE_DIRS.RUBY_INCLUDE_PATHsame as
Ruby_INCLUDE_DIRS.RUBY_LIBRARYsame as
Ruby_LIBRARY.RUBY_VERSIONsame as
Ruby_VERSION.RUBY_FOUNDsame as
Ruby_FOUND.
Hints¶
Ruby_FIND_VIRTUALENVAdded in version 3.18.
This variable defines the handling of virtual environments. It can be left empty or be set to one of the following values:
FIRST: Virtual Ruby environments are searched for first,then the system Ruby installation. This is the default.
ONLY: Only virtual environments are searchedSTANDARD: Only the system Ruby installation is searched.
Virtual environments may be provided by:
rvmRequires that the
MY_RUBY_HOMEenvironment environment is defined.rbenvRequires that
rbenvis installed in~/.rbenv/binor that theRBENV_ROOTenvironment variable is defined.