# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
F i n d R u b y
- - - - - - - -
T h i s m o d u l e d e t e r m i n e s i f R u b y i s i n s t a l l e d a n d f i n d s t h e l o c a t i o n s o f i t s
i n c l u d e f i l e s a n d l i b r a r i e s . R u b y 1 . 8 t h r o u g h 3 . 4 a r e s u p p o r t e d .
T h e m i n i m u m r e q u i r e d v e r s i o n o f R u b y c a n b e s p e c i f i e d u s i n g t h e
s t a n d a r d s y n t a x , e . g .
. . c o d e - b l o c k : : c m a k e
find_package ( Ruby 3.2.6 EXACT REQUIRED )
# OR
find_package ( Ruby 3.2 )
V i r t u a l e n v i r o n m e n t s s u c h a s R V M a r e h a n d l e d a s w e l l , b y p a s s i n g
t h e a r g u m e n t ` ` R u b y _ F I N D _ V I R T U A L E N V ` `
R e s u l t V a r i a b l e s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
T h i s m o d u l e w i l l s e t t h e f o l l o w i n g v a r i a b l e s i n y o u r p r o j e c t :
` ` R u b y _ F O U N D ` `
s e t t o t r u e i f r u b y w a s f o u n d s u c c e s s f u l l y
` ` R u b y _ E X E C U T A B L E ` `
f u l l p a t h t o t h e r u b y b i n a r y
` ` R u b y _ I N C L U D E _ D I R S ` `
i n c l u d e d i r s t o b e u s e d w h e n u s i n g t h e r u b y l i b r a r y
` ` R u b y _ L I B R A R I E S ` `
. . v e r s i o n a d d e d : : 3 . 1 8
l i b r a r i e s n e e d e d t o u s e r u b y f r o m C .
` ` R u b y _ V E R S I O N ` `
t h e v e r s i o n o f r u b y w h i c h w a s f o u n d , e . g . " 3 . 2 . 6 "
` ` R u b y _ V E R S I O N _ M A J O R ` `
R u b y m a j o r v e r s i o n .
` ` R u b y _ V E R S I O N _ M I N O R ` `
R u b y m i n o r v e r s i o n .
` ` R u b y _ V E R S I O N _ P A T C H ` `
R u b y p a t c h v e r s i o n .
. . v e r s i o n c h a n g e d : : 3 . 1 8
P r e v i o u s v e r s i o n s o f C M a k e u s e d t h e ` ` R U B Y _ ` ` p r e f i x f o r a l l v a r i a b l e s .
T h e f o l l o w i n g v a r i a b l e s a r e p r o v i d e d f o r c o m p a t i b i l i t y r e a s o n s ,
d o n ' t u s e t h e m i n n e w c o d e :
` ` R U B Y _ E X E C U T A B L E ` `
s a m e a s R u b y _ E X E C U T A B L E .
` ` R U B Y _ I N C L U D E _ D I R S ` `
s a m e a s R u b y _ I N C L U D E _ D I R S .
` ` R U B Y _ I N C L U D E _ P A T H ` `
s a m e a s R u b y _ I N C L U D E _ D I R S .
` ` R U B Y _ L I B R A R Y ` `
s a m e a s R u b y _ L I B R A R Y .
` ` R U B Y _ V E R S I O N ` `
s a m e a s R u b y _ V E R S I O N .
` ` R U B Y _ F O U N D ` `
s a m e a s R u b y _ F O U N D .
H i n t s
^ ^ ^ ^ ^
. . v e r s i o n a d d e d : : 3 . 1 8
` ` R u b y _ F I N D _ V I R T U A L E N V ` `
T h i s v a r i a b l e d e f i n e s t h e h a n d l i n g o f v i r t u a l e n v i r o n m e n t s m a n a g e d b y
` ` r v m ` ` . I t i s m e a n i n g f u l o n l y w h e n a v i r t u a l e n v i r o n m e n t
i s active ( i.e. the ``rvm`` script has been evaluated or at least the
` ` M Y _ R U B Y _ H O M E ` ` e n v i r o n m e n t v a r i a b l e i s s e t ) .
T h e ` ` R u b y _ F I N D _ V I R T U A L E N V ` ` v a r i a b l e c a n b e s e t t o e m p t y o r
o n e o f t h e f o l l o w i n g :
* ` ` F I R S T ` ` : T h e v i r t u a l e n v i r o n m e n t i s u s e d b e f o r e a n y o t h e r s t a n d a r d
p a t h s t o l o o k - u p f o r t h e i n t e r p r e t e r . T h i s i s t h e d e f a u l t .
* ` ` O N L Y ` ` : O n l y t h e v i r t u a l e n v i r o n m e n t i s u s e d t o l o o k - u p f o r t h e
i n t e r p r e t e r .
* ` ` S T A N D A R D ` ` : T h e v i r t u a l e n v i r o n m e n t i s n o t u s e d t o l o o k - u p f o r t h e
interpreter ( assuming it isn't still in the PATH... )
#]=======================================================================]
# Backwards compatibility
# Define camel case versions of input variables
foreach ( UPPER
R U B Y _ E X E C U T A B L E
R U B Y _ L I B R A R Y
R U B Y _ I N C L U D E _ D I R
R U B Y _ C O N F I G _ I N C L U D E _ D I R
)
if ( DEFINED ${ UPPER } )
string ( REPLACE "RUBY_" "Ruby_" Camel ${ UPPER } )
if ( NOT DEFINED ${ Camel } )
set ( ${ Camel } ${ ${UPPER } } )
endif ( )
endif ( )
endforeach ( )
# Ruby_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'`
# Ruby_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'`
# Ruby_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'`
# Ruby_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'`
# Ruby_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'`
# uncomment the following line to get debug output for this file
# set(_Ruby_DEBUG_OUTPUT TRUE)
# Determine the list of possible names of the ruby executable depending
# on which version of ruby is required
set ( _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby )
# If not specified, allow everything as far back as 1.8.0
if ( NOT DEFINED Ruby_FIND_VERSION_MAJOR )
set ( Ruby_FIND_VERSION "1.8.0" )
set ( Ruby_FIND_VERSION_MAJOR 1 )
set ( Ruby_FIND_VERSION_MINOR 8 )
set ( Ruby_FIND_VERSION_PATCH 0 )
endif ( )
if ( _Ruby_DEBUG_OUTPUT )
message ( "Ruby_FIND_VERSION=${Ruby_FIND_VERSION}" )
message ( "Ruby_FIND_VERSION_MAJOR=${Ruby_FIND_VERSION_MAJOR}" )
message ( "Ruby_FIND_VERSION_MINOR=${Ruby_FIND_VERSION_MINOR}" )
message ( "Ruby_FIND_VERSION_PATCH=${Ruby_FIND_VERSION_PATCH}" )
endif ( )
set ( Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}" )
# Set name of possible executables, ignoring the minor
# Eg:
# 3.2.6 => from ruby34 to ruby32 included
# 3.2 => from ruby34 to ruby32 included
# 3 => from ruby34 to ruby30 included
# empty => from ruby34 to ruby18 included
if ( NOT Ruby_FIND_VERSION_EXACT )
foreach ( _ruby_version RANGE 34 18 -1 )
string ( SUBSTRING "${_ruby_version}" 0 1 _ruby_major_version )
string ( SUBSTRING "${_ruby_version}" 1 1 _ruby_minor_version )
if ( NOT "${_ruby_major_version}${_ruby_minor_version}" VERSION_LESS ${ Ruby_FIND_VERSION_SHORT_NODOT } )
# Append both rubyX.Y and rubyXY (eg: ruby2.7 ruby27)
list ( APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby ${ _ruby_major_version } . ${ _ruby_minor_version } ruby ${ _ruby_major_version } ${ _ruby_minor_version } )
else ( )
break ( )
endif ( )
endforeach ( )
list ( REMOVE_DUPLICATES _Ruby_POSSIBLE_EXECUTABLE_NAMES )
endif ( )
# virtual environments handling (eg RVM)
if ( DEFINED ENV{MY_RUBY_HOME} )
if ( _Ruby_DEBUG_OUTPUT )
message ( "My ruby home is defined: $ENV{MY_RUBY_HOME}" )
endif ( )
if ( DEFINED Ruby_FIND_VIRTUALENV )
if ( NOT Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$" )
message ( AUTHOR_WARNING "FindRuby: ${Ruby_FIND_VIRTUALENV}: invalid value for 'Ruby_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead." )
set ( _Ruby_FIND_VIRTUALENV "FIRST" )
else ( )
set ( _Ruby_FIND_VIRTUALENV ${ Ruby_FIND_VIRTUALENV } )
endif ( )
else ( )
set ( _Ruby_FIND_VIRTUALENV FIRST )
endif ( )
else ( )
if ( DEFINED Ruby_FIND_VIRTUALENV )
message ( "Environment variable MY_RUBY_HOME isn't set, defaulting back to Ruby_FIND_VIRTUALENV=STANDARD" )
endif ( )
set ( _Ruby_FIND_VIRTUALENV STANDARD )
endif ( )
if ( _Ruby_DEBUG_OUTPUT )
message ( "_Ruby_POSSIBLE_EXECUTABLE_NAMES=${_Ruby_POSSIBLE_EXECUTABLE_NAMES}" )
message ( "_Ruby_FIND_VIRTUALENV=${_Ruby_FIND_VIRTUALENV}" )
endif ( )
function ( _RUBY_VALIDATE_INTERPRETER )
if ( NOT Ruby_EXECUTABLE )
return ( )
endif ( )
cmake_parse_arguments ( PARSE_ARGV 0 _RVI "EXACT;CHECK_EXISTS" "" "" )
if ( _RVI_UNPARSED_ARGUMENTS )
set ( expected_version ${ _RVI_UNPARSED_ARGUMENTS } )
else ( )
unset ( expected_version )
endif ( )
if ( _RVI_CHECK_EXISTS AND NOT EXISTS "${Ruby_EXECUTABLE}" )
# interpreter does not exist anymore
set ( _Ruby_Interpreter_REASON_FAILURE "Cannot find the interpreter \" ${ Ruby_EXECUTABLE } \"")
set_property ( CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND" )
return ( )
endif ( )
# Check the version it returns
# executable found must have a specific version
execute_process ( COMMAND "${Ruby_EXECUTABLE}" -e "puts RUBY_VERSION"
R E S U L T _ V A R I A B L E r e s u l t
O U T P U T _ V A R I A B L E v e r s i o n
E R R O R _ Q U I E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( result OR ( _RVI_EXACT AND NOT version VERSION_EQUAL expected_version ) OR ( version VERSION_LESS expected_version ) )
# interpreter not usable or has wrong major version
if ( result )
set ( _Ruby_Interpreter_REASON_FAILURE "Cannot use the interpreter \" ${ Ruby_EXECUTABLE } \"")
else ( )
set ( _Ruby_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \" ${ Ruby_EXECUTABLE } \"")
endif ( )
set_property ( CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND" )
return ( )
endif ( )
endfunction ( )
while ( 1 )
# Virtual environments handling
if ( _Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$" )
if ( _Ruby_DEBUG_OUTPUT )
message ( "Inside Matches" )
endif ( )
find_program ( Ruby_EXECUTABLE
N A M E S $ { _ R u b y _ P O S S I B L E _ E X E C U T A B L E _ N A M E S }
N A M E S _ P E R _ D I R
P A T H S E N V M Y _ R U B Y _ H O M E
P A T H _ S U F F I X E S b i n S c r i p t s
N O _ C M A K E _ P A T H
N O _ C M A K E _ E N V I R O N M E N T _ P A T H
N O _ S Y S T E M _ E N V I R O N M E N T _ P A T H
N O _ C M A K E _ S Y S T E M _ P A T H )
if ( _Ruby_DEBUG_OUTPUT )
message ( "Ruby_EXECUTABLE=${Ruby_EXECUTABLE}" )
endif ( )
_RUBY_VALIDATE_INTERPRETER ( ${ Ruby_FIND_VERSION } } )
if ( Ruby_EXECUTABLE )
break ( )
endif ( )
if ( NOT _Ruby_FIND_VIRTUALENV STREQUAL "ONLY" )
break ( )
endif ( )
elseif ( _Ruby_DEBUG_OUTPUT )
message ( "_Ruby_FIND_VIRTUALENV doesn't match: ${_Ruby_FIND_VIRTUALENV}" )
endif ( )
# try using standard paths
find_program ( Ruby_EXECUTABLE
N A M E S $ { _ R u b y _ P O S S I B L E _ E X E C U T A B L E _ N A M E S }
N A M E S _ P E R _ D I R )
_RUBY_VALIDATE_INTERPRETER ( ${ Ruby_FIND_VERSION } )
if ( Ruby_EXECUTABLE )
break ( )
else ( )
# Remove first entry from names list.
LIST ( REMOVE_AT _Ruby_POSSIBLE_EXECUTABLE_NAMES 0 )
# If the list is now empty, abort.
if ( NOT _Ruby_POSSIBLE_EXECUTABLE_NAMES )
break ( )
else ( )
# Otherwise, continue with the remaining list. Make sure that we clear
# the cached variable.
unset ( Ruby_EXECUTABLE CACHE )
endif ( )
endif ( )
endwhile ( )
if ( Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR )
function ( _RUBY_CONFIG_VAR RBVAR OUTVAR )
execute_process ( COMMAND ${ Ruby_EXECUTABLE } -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']"
R E S U L T _ V A R I A B L E _ R u b y _ S U C C E S S
O U T P U T _ V A R I A B L E _ R u b y _ O U T P U T
E R R O R _ Q U I E T )
if ( _Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "" )
execute_process ( COMMAND ${ Ruby_EXECUTABLE } -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
R E S U L T _ V A R I A B L E _ R u b y _ S U C C E S S
O U T P U T _ V A R I A B L E _ R u b y _ O U T P U T
E R R O R _ Q U I E T )
endif ( )
set ( ${ OUTVAR } "${_Ruby_OUTPUT}" PARENT_SCOPE )
endfunction ( )
# query the ruby version
_RUBY_CONFIG_VAR ( "MAJOR" Ruby_VERSION_MAJOR )
_RUBY_CONFIG_VAR ( "MINOR" Ruby_VERSION_MINOR )
_RUBY_CONFIG_VAR ( "TEENY" Ruby_VERSION_PATCH )
# query the different directories
_RUBY_CONFIG_VAR ( "archdir" Ruby_ARCH_DIR )
_RUBY_CONFIG_VAR ( "arch" Ruby_ARCH )
_RUBY_CONFIG_VAR ( "rubyhdrdir" Ruby_HDR_DIR )
_RUBY_CONFIG_VAR ( "rubyarchhdrdir" Ruby_ARCHHDR_DIR )
_RUBY_CONFIG_VAR ( "libdir" Ruby_POSSIBLE_LIB_DIR )
_RUBY_CONFIG_VAR ( "rubylibdir" Ruby_RUBY_LIB_DIR )
# site_ruby
_RUBY_CONFIG_VAR ( "sitearchdir" Ruby_SITEARCH_DIR )
_RUBY_CONFIG_VAR ( "sitelibdir" Ruby_SITELIB_DIR )
# vendor_ruby available ?
execute_process ( COMMAND ${ Ruby_EXECUTABLE } -r vendor-specific -e "print 'true'"
O U T P U T _ V A R I A B L E R u b y _ H A S _ V E N D O R _ R U B Y E R R O R _ Q U I E T )
if ( Ruby_HAS_VENDOR_RUBY )
_RUBY_CONFIG_VAR ( "vendorlibdir" Ruby_VENDORLIB_DIR )
_RUBY_CONFIG_VAR ( "vendorarchdir" Ruby_VENDORARCH_DIR )
endif ( )
# save the results in the cache so we don't have to run ruby the next time again
set ( Ruby_VERSION_MAJOR ${ Ruby_VERSION_MAJOR } CACHE PATH "The Ruby major version" FORCE )
set ( Ruby_VERSION_MINOR ${ Ruby_VERSION_MINOR } CACHE PATH "The Ruby minor version" FORCE )
set ( Ruby_VERSION_PATCH ${ Ruby_VERSION_PATCH } CACHE PATH "The Ruby patch version" FORCE )
set ( Ruby_ARCH_DIR ${ Ruby_ARCH_DIR } CACHE PATH "The Ruby arch dir" FORCE )
set ( Ruby_HDR_DIR ${ Ruby_HDR_DIR } CACHE PATH "The Ruby header dir (1.9+)" FORCE )
set ( Ruby_ARCHHDR_DIR ${ Ruby_ARCHHDR_DIR } CACHE PATH "The Ruby arch header dir (2.0+)" FORCE )
set ( Ruby_POSSIBLE_LIB_DIR ${ Ruby_POSSIBLE_LIB_DIR } CACHE PATH "The Ruby lib dir" FORCE )
set ( Ruby_RUBY_LIB_DIR ${ Ruby_RUBY_LIB_DIR } CACHE PATH "The Ruby ruby-lib dir" FORCE )
set ( Ruby_SITEARCH_DIR ${ Ruby_SITEARCH_DIR } CACHE PATH "The Ruby site arch dir" FORCE )
set ( Ruby_SITELIB_DIR ${ Ruby_SITELIB_DIR } CACHE PATH "The Ruby site lib dir" FORCE )
set ( Ruby_HAS_VENDOR_RUBY ${ Ruby_HAS_VENDOR_RUBY } CACHE BOOL "Vendor Ruby is available" FORCE )
set ( Ruby_VENDORARCH_DIR ${ Ruby_VENDORARCH_DIR } CACHE PATH "The Ruby vendor arch dir" FORCE )
set ( Ruby_VENDORLIB_DIR ${ Ruby_VENDORLIB_DIR } CACHE PATH "The Ruby vendor lib dir" FORCE )
mark_as_advanced (
R u b y _ A R C H _ D I R
R u b y _ A R C H
R u b y _ H D R _ D I R
R u b y _ A R C H H D R _ D I R
R u b y _ P O S S I B L E _ L I B _ D I R
R u b y _ R U B Y _ L I B _ D I R
R u b y _ S I T E A R C H _ D I R
R u b y _ S I T E L I B _ D I R
R u b y _ H A S _ V E N D O R _ R U B Y
R u b y _ V E N D O R A R C H _ D I R
R u b y _ V E N D O R L I B _ D I R
R u b y _ V E R S I O N _ M A J O R
R u b y _ V E R S I O N _ M I N O R
R u b y _ V E R S I O N _ P A T C H
)
endif ( )
# In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling)
# try to detect which version we found. This is not too good.
if ( Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR )
# by default assume 1.8.0
set ( Ruby_VERSION_MAJOR 1 )
set ( Ruby_VERSION_MINOR 8 )
set ( Ruby_VERSION_PATCH 0 )
# check whether we found 1.9.x
if ( ${ Ruby_EXECUTABLE } MATCHES "ruby1\\.?9" )
set ( Ruby_VERSION_MAJOR 1 )
set ( Ruby_VERSION_MINOR 9 )
endif ( )
# check whether we found 2.[0-7].x
if ( ${ Ruby_EXECUTABLE } MATCHES "ruby2" )
set ( Ruby_VERSION_MAJOR 2 )
string ( REGEX_REPLACE ${ Ruby_EXECUTABLE } "ruby2\\.?([0-7])" "\\1" Ruby_VERSION_MINOR )
endif ( )
# check whether we found 3.[0-1].x
if ( ${ Ruby_EXECUTABLE } MATCHES "ruby3" )
set ( Ruby_VERSION_MAJOR 3 )
string ( REGEX_REPLACE ${ Ruby_EXECUTABLE } "ruby3\\.?([0-1])" "\\1" Ruby_VERSION_MINOR )
endif ( )
endif ( )
if ( Ruby_VERSION_MAJOR )
set ( Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}" )
set ( _Ruby_VERSION_SHORT "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}" )
set ( _Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}" )
set ( _Ruby_NODOT_VERSION "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}" )
set ( _Ruby_NODOT_VERSION_ZERO_PATCH "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}0" )
endif ( )
# FIXME: Currently we require both the interpreter and development components to be found
# in order to use either. See issue #20474.
find_path ( Ruby_INCLUDE_DIR
N A M E S r u b y . h
H I N T S
$ { R u b y _ H D R _ D I R }
$ { R u b y _ A R C H _ D I R }
/ u s r / l i b / r u b y / $ { _ R u b y _ V E R S I O N _ S H O R T } / i 5 8 6 - l i n u x - g n u /
)
set ( Ruby_INCLUDE_DIRS ${ Ruby_INCLUDE_DIR } )
# if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir
if ( Ruby_FIND_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_HDR_DIR )
find_path ( Ruby_CONFIG_INCLUDE_DIR
N A M E S r u b y / c o n f i g . h c o n f i g . h
H I N T S
$ { R u b y _ H D R _ D I R } / $ { R u b y _ A R C H }
$ { R u b y _ A R C H _ D I R }
$ { R u b y _ A R C H H D R _ D I R }
)
set ( Ruby_INCLUDE_DIRS ${ Ruby_INCLUDE_DIRS } ${ Ruby_CONFIG_INCLUDE_DIR } )
endif ( )
# Determine the list of possible names for the ruby library
set ( _Ruby_POSSIBLE_LIB_NAMES ruby ruby-static ruby ${ _Ruby_VERSION_SHORT } ruby ${ _Ruby_VERSION_SHORT_NODOT } ruby ${ _Ruby_NODOT_VERSION } ruby- ${ _Ruby_VERSION_SHORT } ruby- ${ Ruby_VERSION } )
if ( WIN32 )
set ( _Ruby_POSSIBLE_MSVC_RUNTIMES "ucrt;msvcrt;vcruntime140;vcruntime140_1" )
if ( MSVC_TOOLSET_VERSION )
list ( APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr${MSVC_TOOLSET_VERSION}" )
else ( )
list ( APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr" )
endif ( )
set ( _Ruby_POSSIBLE_VERSION_SUFFICES "${_Ruby_NODOT_VERSION};${_Ruby_NODOT_VERSION_ZERO_PATCH}" )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( _Ruby_POSSIBLE_ARCH_PREFIXS "libx64-;x64-" )
else ( )
set ( _Ruby_POSSIBLE_ARCH_PREFIXS "lib" )
endif ( )
foreach ( _Ruby_MSVC_RUNTIME ${ _Ruby_POSSIBLE_MSVC_RUNTIMES } )
foreach ( _Ruby_VERSION_SUFFIX ${ _Ruby_POSSIBLE_VERSION_SUFFICES } )
foreach ( _Ruby_ARCH_PREFIX ${ _Ruby_POSSIBLE_ARCH_PREFIXS } )
list ( APPEND _Ruby_POSSIBLE_LIB_NAMES
" $ { _ R u b y _ A R C H _ P R E F I X } $ { _ R u b y _ M S V C _ R U N T I M E } - r u b y $ { _ R u b y _ V E R S I O N _ S U F F I X } "
" $ { _ R u b y _ A R C H _ P R E F I X } $ { _ R u b y _ M S V C _ R U N T I M E } - r u b y $ { _ R u b y _ V E R S I O N _ S U F F I X } - s t a t i c " )
endforeach ( )
endforeach ( )
endforeach ( )
endif ( )
find_library ( Ruby_LIBRARY NAMES ${ _Ruby_POSSIBLE_LIB_NAMES } HINTS ${ Ruby_POSSIBLE_LIB_DIR } )
set ( _Ruby_REQUIRED_VARS Ruby_EXECUTABLE Ruby_INCLUDE_DIR Ruby_LIBRARY )
if ( _Ruby_VERSION_SHORT_NODOT GREATER 18 )
list ( APPEND _Ruby_REQUIRED_VARS Ruby_CONFIG_INCLUDE_DIR )
endif ( )
if ( _Ruby_DEBUG_OUTPUT )
message ( STATUS "--------FindRuby.cmake debug------------" )
message ( STATUS "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}" )
message ( STATUS "_Ruby_POSSIBLE_LIB_NAMES: ${_Ruby_POSSIBLE_LIB_NAMES}" )
message ( STATUS "Ruby_ARCH_DIR: ${Ruby_ARCH_DIR}" )
message ( STATUS "Ruby_HDR_DIR: ${Ruby_HDR_DIR}" )
message ( STATUS "Ruby_POSSIBLE_LIB_DIR: ${Ruby_POSSIBLE_LIB_DIR}" )
message ( STATUS "Found Ruby_VERSION: \" ${ Ruby_VERSION } \" , short: \"${_Ruby_VERSION_SHORT}\", nodot: \"${_Ruby_VERSION_SHORT_NODOT}\"")
message ( STATUS "_Ruby_REQUIRED_VARS: ${_Ruby_REQUIRED_VARS}" )
message ( STATUS "Ruby_EXECUTABLE: ${Ruby_EXECUTABLE}" )
message ( STATUS "Ruby_LIBRARY: ${Ruby_LIBRARY}" )
message ( STATUS "Ruby_INCLUDE_DIR: ${Ruby_INCLUDE_DIR}" )
message ( STATUS "Ruby_CONFIG_INCLUDE_DIR: ${Ruby_CONFIG_INCLUDE_DIR}" )
message ( STATUS "--------------------" )
endif ( )
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindPackageHandleStandardArgs.cmake )
FIND_PACKAGE_HANDLE_STANDARD_ARGS ( Ruby REQUIRED_VARS ${ _Ruby_REQUIRED_VARS }
V E R S I O N _ V A R R u b y _ V E R S I O N )
if ( Ruby_FOUND )
set ( Ruby_LIBRARIES ${ Ruby_LIBRARY } )
endif ( )
mark_as_advanced (
R u b y _ E X E C U T A B L E
R u b y _ L I B R A R Y
R u b y _ I N C L U D E _ D I R
R u b y _ C O N F I G _ I N C L U D E _ D I R
)
# Set some variables for compatibility with previous version of this file (no need to provide a CamelCase version of that...)
set ( RUBY_POSSIBLE_LIB_PATH ${ Ruby_POSSIBLE_LIB_DIR } )
set ( RUBY_RUBY_LIB_PATH ${ Ruby_RUBY_LIB_DIR } )
set ( RUBY_INCLUDE_PATH ${ Ruby_INCLUDE_DIRS } )
# Backwards compatibility
# Define upper case versions of output variables
foreach ( Camel
R u b y _ E X E C U T A B L E
R u b y _ I N C L U D E _ D I R S
R u b y _ L I B R A R Y
R u b y _ V E R S I O N
R u b y _ V E R S I O N _ M A J O R
R u b y _ V E R S I O N _ M I N O R
R u b y _ V E R S I O N _ P A T C H
R u b y _ A R C H _ D I R
R u b y _ A R C H
R u b y _ H D R _ D I R
R u b y _ A R C H H D R _ D I R
R u b y _ P O S S I B L E _ L I B _ D I R
R u b y _ R U B Y _ L I B _ D I R
R u b y _ S I T E A R C H _ D I R
R u b y _ S I T E L I B _ D I R
R u b y _ H A S _ V E N D O R _ R U B Y
R u b y _ V E N D O R A R C H _ D I R
R u b y _ V E N D O R L I B _ D I R
)
string ( TOUPPER ${ Camel } UPPER )
set ( ${ UPPER } ${ ${Camel } } )
endforeach ( )