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_FOUND
- set to true if ruby was found successfully 
- Ruby_EXECUTABLE
- full path to the ruby binary 
- Ruby_INCLUDE_DIRS
- include dirs to be used when using the ruby library 
- Ruby_LIBRARIES
- Added in version 3.18: libraries needed to use ruby from C. 
- Ruby_VERSION
- the version of ruby which was found, e.g. "3.2.6" 
- Ruby_VERSION_MAJOR
- Ruby major version. 
- Ruby_VERSION_MINOR
- Ruby minor version. 
- Ruby_VERSION_PATCH
- Ruby 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_EXECUTABLE
- same as - Ruby_EXECUTABLE.
- RUBY_INCLUDE_DIRS
- same as - Ruby_INCLUDE_DIRS.
- RUBY_INCLUDE_PATH
- same as - Ruby_INCLUDE_DIRS.
- RUBY_LIBRARY
- same as - Ruby_LIBRARY.
- RUBY_VERSION
- same as - Ruby_VERSION.
- RUBY_FOUND
- same as - Ruby_FOUND.
Hints¶
- Ruby_FIND_VIRTUALENV
- Added 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 searched
- STANDARD: Only the system Ruby installation is searched.
 - Virtual environments may be provided by: - rvm
- Requires that the - MY_RUBY_HOMEenvironment environment is defined.
- rbenv
- Requires that - rbenvis installed in- ~/.rbenv/binor that the- RBENV_ROOTenvironment variable is defined.
 
