FindRuby¶
Finds Ruby installation and the locations of its include files and libraries:
find_package(Ruby [<version>] [...])
Ruby is a general-purpose programming language. This module supports Ruby 1.8 through 3.4. Virtual environments, such as RVM or RBENV, are also supported.
Result Variables¶
This module defines the following variables:
Ruby_FOUNDAdded in version 3.3.
Boolean indicating whether (the requested version of) ruby was found.
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.
Ruby_EXECUTABLEThe full 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.
Changed in version 3.18: Previous versions of CMake used the RUBY_ prefix for all variables.
Hints¶
This module accepts the following variables:
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.
Deprecated Variables¶
The following variables are provided for backward compatibility:
Deprecated since version 4.0: The following variables are deprecated. See policy CMP0185.
RUBY_FOUNDSame as
Ruby_FOUND.RUBY_VERSIONSame as
Ruby_VERSION.RUBY_EXECUTABLESame as
Ruby_EXECUTABLE.RUBY_INCLUDE_DIRSSame as
Ruby_INCLUDE_DIRS.RUBY_INCLUDE_PATHSame as
Ruby_INCLUDE_DIRS.RUBY_LIBRARYSame as
Ruby_LIBRARY.
Examples¶
Finding Ruby and specifying the minimum required version:
find_package(Ruby 3.2.6 EXACT REQUIRED)
# or
find_package(Ruby 3.2)