W3cubDocs

/CMake 3.19

FindRuby

Find Ruby

This module finds if Ruby is installed and determines where the include files and libraries are. Ruby 1.8 through 2.7 are supported.

The minimum required version of Ruby can be specified using the standard syntax, e.g.

find_package(Ruby 2.5.1 EXACT REQUIRED)
# OR
find_package(Ruby 2.4)

It also determines what the name of the library is.

Virtual environments such as RVM are handled as well, by passing the argument Ruby_FIND_VIRTUALENV

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

libraries needed to use ruby from C.

Ruby_VERSION

the version of ruby which was found, e.g. “1.8.7”

Ruby_VERSION_MAJOR

Ruby major version.

Ruby_VERSION_MINOR

Ruby minor version.

Ruby_VERSION_PATCH

Ruby patch version.

The following variables are also provided for compatibility reasons, don’t use them in new code:

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_ROOT_DIR

Define the root directory of a Ruby installation.

Ruby_FIND_VIRTUALENV

This variable defines the handling of virtual environments managed by rvm. It is meaningful only when a virtual environment is active (i.e. the rvm script has been evaluated or at least the MY_RUBY_HOME environment variable is set). The Ruby_FIND_VIRTUALENV variable can be set to empty or one of the following:

  • FIRST: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default.
  • ONLY: Only the virtual environment is used to look-up for the interpreter.
  • STANDARD: The virtual environment is not used to look-up for the interpreter (assuming it isn’t still in the PATH…)

© 2000–2020 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.19/module/FindRuby.html