1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindRuby 6-------- 7 8Find Ruby 9 10This module finds if Ruby is installed and determines where the 11include files and libraries are. Ruby 1.8 through 2.7 are 12supported. 13 14The minimum required version of Ruby can be specified using the 15standard syntax, e.g. 16 17.. code-block:: cmake 18 19 find_package(Ruby 2.5.1 EXACT REQUIRED) 20 # OR 21 find_package(Ruby 2.4) 22 23It also determines what the name of the library is. 24 25Virtual environments such as RVM are handled as well, by passing 26the argument ``Ruby_FIND_VIRTUALENV`` 27 28Result Variables 29^^^^^^^^^^^^^^^^ 30 31This module will set the following variables in your project: 32 33``Ruby_FOUND`` 34 set to true if ruby was found successfully 35``Ruby_EXECUTABLE`` 36 full path to the ruby binary 37``Ruby_INCLUDE_DIRS`` 38 include dirs to be used when using the ruby library 39``Ruby_LIBRARIES`` 40 .. versionadded:: 3.18 41 libraries needed to use ruby from C. 42``Ruby_VERSION`` 43 the version of ruby which was found, e.g. "1.8.7" 44``Ruby_VERSION_MAJOR`` 45 Ruby major version. 46``Ruby_VERSION_MINOR`` 47 Ruby minor version. 48``Ruby_VERSION_PATCH`` 49 Ruby patch version. 50 51.. versionchanged:: 3.18 52 Previous versions of CMake used the ``RUBY_`` prefix for all variables. 53 The following variables are provided for compatibility reasons, 54 don't use them in new code: 55 56``RUBY_EXECUTABLE`` 57 same as Ruby_EXECUTABLE. 58``RUBY_INCLUDE_DIRS`` 59 same as Ruby_INCLUDE_DIRS. 60``RUBY_INCLUDE_PATH`` 61 same as Ruby_INCLUDE_DIRS. 62``RUBY_LIBRARY`` 63 same as Ruby_LIBRARY. 64``RUBY_VERSION`` 65 same as Ruby_VERSION. 66``RUBY_FOUND`` 67 same as Ruby_FOUND. 68 69Hints 70^^^^^ 71 72.. versionadded:: 3.18 73 74``Ruby_ROOT_DIR`` 75 Define the root directory of a Ruby installation. 76 77``Ruby_FIND_VIRTUALENV`` 78 This variable defines the handling of virtual environments managed by 79 ``rvm``. It is meaningful only when a virtual environment 80 is active (i.e. the ``rvm`` script has been evaluated or at least the 81 ``MY_RUBY_HOME`` environment variable is set). 82 The ``Ruby_FIND_VIRTUALENV`` variable can be set to empty or 83 one of the following: 84 85 * ``FIRST``: The virtual environment is used before any other standard 86 paths to look-up for the interpreter. This is the default. 87 * ``ONLY``: Only the virtual environment is used to look-up for the 88 interpreter. 89 * ``STANDARD``: The virtual environment is not used to look-up for the 90 interpreter (assuming it isn't still in the PATH...) 91 92#]=======================================================================] 93 94# Backwards compatibility 95# Define camel case versions of input variables 96foreach(UPPER 97 RUBY_EXECUTABLE 98 RUBY_LIBRARY 99 RUBY_INCLUDE_DIR 100 RUBY_CONFIG_INCLUDE_DIR 101 ) 102 if (DEFINED ${UPPER}) 103 string(REPLACE "RUBY_" "Ruby_" Camel ${UPPER}) 104 if (NOT DEFINED ${Camel}) 105 set(${Camel} ${${UPPER}}) 106 endif() 107 endif() 108endforeach() 109 110# Ruby_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'` 111# Ruby_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'` 112# Ruby_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'` 113# Ruby_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'` 114# Ruby_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'` 115 116# uncomment the following line to get debug output for this file 117# set(_Ruby_DEBUG_OUTPUT TRUE) 118 119# Determine the list of possible names of the ruby executable depending 120# on which version of ruby is required 121set(_Ruby_POSSIBLE_EXECUTABLE_NAMES ruby) 122 123# If not specified, allow everything as far back as 1.8.0 124if(NOT DEFINED Ruby_FIND_VERSION_MAJOR) 125 set(Ruby_FIND_VERSION "1.8.0") 126 set(Ruby_FIND_VERSION_MAJOR 1) 127 set(Ruby_FIND_VERSION_MINOR 8) 128 set(Ruby_FIND_VERSION_PATCH 0) 129endif() 130 131if(_Ruby_DEBUG_OUTPUT) 132 message("Ruby_FIND_VERSION=${Ruby_FIND_VERSION}") 133 message("Ruby_FIND_VERSION_MAJOR=${Ruby_FIND_VERSION_MAJOR}") 134 message("Ruby_FIND_VERSION_MINOR=${Ruby_FIND_VERSION_MINOR}") 135 message("Ruby_FIND_VERSION_PATCH=${Ruby_FIND_VERSION_PATCH}") 136endif() 137 138set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}") 139 140# Set name of possible executables, ignoring the minor 141# Eg: 142# 2.1.1 => from ruby27 to ruby21 included 143# 2.1 => from ruby27 to ruby21 included 144# 2 => from ruby26 to ruby20 included 145# empty => from ruby27 to ruby18 included 146if(NOT Ruby_FIND_VERSION_EXACT) 147 148 foreach(_ruby_version RANGE 27 18 -1) 149 string(SUBSTRING "${_ruby_version}" 0 1 _ruby_major_version) 150 string(SUBSTRING "${_ruby_version}" 1 1 _ruby_minor_version) 151 152 if(NOT "${_ruby_major_version}${_ruby_minor_version}" VERSION_LESS ${Ruby_FIND_VERSION_SHORT_NODOT}) 153 # Append both rubyX.Y and rubyXY (eg: ruby2.7 ruby27) 154 list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby${_ruby_major_version}.${_ruby_minor_version} ruby${_ruby_major_version}${_ruby_minor_version}) 155 else() 156 break() 157 endif() 158 159 endforeach() 160 161 list(REMOVE_DUPLICATES _Ruby_POSSIBLE_EXECUTABLE_NAMES) 162endif() 163 164# virtual environments handling (eg RVM) 165if (DEFINED ENV{MY_RUBY_HOME}) 166 if(_Ruby_DEBUG_OUTPUT) 167 message("My ruby home is defined: $ENV{MY_RUBY_HOME}") 168 endif() 169 170 if (DEFINED Ruby_FIND_VIRTUALENV) 171 if (NOT Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$") 172 message (AUTHOR_WARNING "FindRuby: ${Ruby_FIND_VIRTUALENV}: invalid value for 'Ruby_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.") 173 set (_Ruby_FIND_VIRTUALENV "FIRST") 174 else() 175 set (_Ruby_FIND_VIRTUALENV ${Ruby_FIND_VIRTUALENV}) 176 endif() 177 else() 178 set (_Ruby_FIND_VIRTUALENV FIRST) 179 endif() 180else() 181 if (DEFINED Ruby_FIND_VIRTUALENV) 182 message("Environment variable MY_RUBY_HOME isn't set, defaulting back to Ruby_FIND_VIRTUALENV=STANDARD") 183 endif() 184 set (_Ruby_FIND_VIRTUALENV STANDARD) 185endif() 186 187if(_Ruby_DEBUG_OUTPUT) 188 message("_Ruby_POSSIBLE_EXECUTABLE_NAMES=${_Ruby_POSSIBLE_EXECUTABLE_NAMES}") 189 message("_Ruby_FIND_VIRTUALENV=${_Ruby_FIND_VIRTUALENV}") 190endif() 191 192function (_RUBY_VALIDATE_INTERPRETER) 193 if (NOT Ruby_EXECUTABLE) 194 return() 195 endif() 196 197 cmake_parse_arguments (PARSE_ARGV 0 _RVI "EXACT;CHECK_EXISTS" "" "") 198 if (_RVI_UNPARSED_ARGUMENTS) 199 set (expected_version ${_RVI_UNPARSED_ARGUMENTS}) 200 else() 201 unset (expected_version) 202 endif() 203 204 if (_RVI_CHECK_EXISTS AND NOT EXISTS "${Ruby_EXECUTABLE}") 205 # interpreter does not exist anymore 206 set (_Ruby_Interpreter_REASON_FAILURE "Cannot find the interpreter \"${Ruby_EXECUTABLE}\"") 207 set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND") 208 return() 209 endif() 210 211 # Check the version it returns 212 # executable found must have a specific version 213 execute_process (COMMAND "${Ruby_EXECUTABLE}" -e "puts RUBY_VERSION" 214 RESULT_VARIABLE result 215 OUTPUT_VARIABLE version 216 ERROR_QUIET 217 OUTPUT_STRIP_TRAILING_WHITESPACE) 218 if (result OR (_RVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) 219 # interpreter not usable or has wrong major version 220 if (result) 221 set (_Ruby_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${Ruby_EXECUTABLE}\"") 222 else() 223 set (_Ruby_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${Ruby_EXECUTABLE}\"") 224 endif() 225 set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND") 226 return() 227 endif() 228 229endfunction() 230 231while(1) 232 # Virtual environments handling 233 if(_Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") 234 if(_Ruby_DEBUG_OUTPUT) 235 message("Inside Matches") 236 endif() 237 find_program (Ruby_EXECUTABLE 238 NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} 239 NAMES_PER_DIR 240 PATHS ENV MY_RUBY_HOME 241 PATH_SUFFIXES bin Scripts 242 NO_CMAKE_PATH 243 NO_CMAKE_ENVIRONMENT_PATH 244 NO_SYSTEM_ENVIRONMENT_PATH 245 NO_CMAKE_SYSTEM_PATH) 246 247 if(_Ruby_DEBUG_OUTPUT) 248 message("Ruby_EXECUTABLE=${Ruby_EXECUTABLE}") 249 endif() 250 251 _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}}) 252 if(Ruby_EXECUTABLE) 253 break() 254 endif() 255 if(NOT _Ruby_FIND_VIRTUALENV STREQUAL "ONLY") 256 break() 257 endif() 258 elseif(_Ruby_DEBUG_OUTPUT) 259 message("_Ruby_FIND_VIRTUALENV doesn't match: ${_Ruby_FIND_VIRTUALENV}") 260 endif() 261 262 # try using standard paths 263 find_program (Ruby_EXECUTABLE 264 NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} 265 NAMES_PER_DIR) 266 _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}) 267 if (Ruby_EXECUTABLE) 268 break() 269 endif() 270 271 break() 272endwhile() 273 274if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) 275 function(_RUBY_CONFIG_VAR RBVAR OUTVAR) 276 execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']" 277 RESULT_VARIABLE _Ruby_SUCCESS 278 OUTPUT_VARIABLE _Ruby_OUTPUT 279 ERROR_QUIET) 280 if(_Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "") 281 execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']" 282 RESULT_VARIABLE _Ruby_SUCCESS 283 OUTPUT_VARIABLE _Ruby_OUTPUT 284 ERROR_QUIET) 285 endif() 286 set(${OUTVAR} "${_Ruby_OUTPUT}" PARENT_SCOPE) 287 endfunction() 288 289 290 # query the ruby version 291 _RUBY_CONFIG_VAR("MAJOR" Ruby_VERSION_MAJOR) 292 _RUBY_CONFIG_VAR("MINOR" Ruby_VERSION_MINOR) 293 _RUBY_CONFIG_VAR("TEENY" Ruby_VERSION_PATCH) 294 295 # query the different directories 296 _RUBY_CONFIG_VAR("archdir" Ruby_ARCH_DIR) 297 _RUBY_CONFIG_VAR("arch" Ruby_ARCH) 298 _RUBY_CONFIG_VAR("rubyhdrdir" Ruby_HDR_DIR) 299 _RUBY_CONFIG_VAR("rubyarchhdrdir" Ruby_ARCHHDR_DIR) 300 _RUBY_CONFIG_VAR("libdir" Ruby_POSSIBLE_LIB_DIR) 301 _RUBY_CONFIG_VAR("rubylibdir" Ruby_RUBY_LIB_DIR) 302 303 # site_ruby 304 _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR) 305 _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR) 306 307 # vendor_ruby available ? 308 execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'" 309 OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY ERROR_QUIET) 310 311 if(Ruby_HAS_VENDOR_RUBY) 312 _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR) 313 _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR) 314 endif() 315 316 # save the results in the cache so we don't have to run ruby the next time again 317 set(Ruby_VERSION_MAJOR ${Ruby_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE) 318 set(Ruby_VERSION_MINOR ${Ruby_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE) 319 set(Ruby_VERSION_PATCH ${Ruby_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE) 320 set(Ruby_ARCH_DIR ${Ruby_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE) 321 set(Ruby_HDR_DIR ${Ruby_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE) 322 set(Ruby_ARCHHDR_DIR ${Ruby_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE) 323 set(Ruby_POSSIBLE_LIB_DIR ${Ruby_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE) 324 set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE) 325 set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE) 326 set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE) 327 set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE) 328 set(Ruby_VENDORARCH_DIR ${Ruby_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE) 329 set(Ruby_VENDORLIB_DIR ${Ruby_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE) 330 331 mark_as_advanced( 332 Ruby_ARCH_DIR 333 Ruby_ARCH 334 Ruby_HDR_DIR 335 Ruby_ARCHHDR_DIR 336 Ruby_POSSIBLE_LIB_DIR 337 Ruby_RUBY_LIB_DIR 338 Ruby_SITEARCH_DIR 339 Ruby_SITELIB_DIR 340 Ruby_HAS_VENDOR_RUBY 341 Ruby_VENDORARCH_DIR 342 Ruby_VENDORLIB_DIR 343 Ruby_VERSION_MAJOR 344 Ruby_VERSION_MINOR 345 Ruby_VERSION_PATCH 346 ) 347endif() 348 349# In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling) 350# try to detect which version we found. This is not too good. 351if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) 352 # by default assume 1.8.0 353 set(Ruby_VERSION_MAJOR 1) 354 set(Ruby_VERSION_MINOR 8) 355 set(Ruby_VERSION_PATCH 0) 356 # check whether we found 1.9.x 357 if(${Ruby_EXECUTABLE} MATCHES "ruby1\\.?9") 358 set(Ruby_VERSION_MAJOR 1) 359 set(Ruby_VERSION_MINOR 9) 360 endif() 361 # check whether we found 2.0.x 362 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?0") 363 set(Ruby_VERSION_MAJOR 2) 364 set(Ruby_VERSION_MINOR 0) 365 endif() 366 # check whether we found 2.1.x 367 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?1") 368 set(Ruby_VERSION_MAJOR 2) 369 set(Ruby_VERSION_MINOR 1) 370 endif() 371 # check whether we found 2.2.x 372 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?2") 373 set(Ruby_VERSION_MAJOR 2) 374 set(Ruby_VERSION_MINOR 2) 375 endif() 376 # check whether we found 2.3.x 377 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?3") 378 set(Ruby_VERSION_MAJOR 2) 379 set(Ruby_VERSION_MINOR 3) 380 endif() 381 # check whether we found 2.4.x 382 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?4") 383 set(Ruby_VERSION_MAJOR 2) 384 set(Ruby_VERSION_MINOR 4) 385 endif() 386 # check whether we found 2.5.x 387 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?5") 388 set(Ruby_VERSION_MAJOR 2) 389 set(Ruby_VERSION_MINOR 5) 390 endif() 391 # check whether we found 2.6.x 392 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?6") 393 set(Ruby_VERSION_MAJOR 2) 394 set(Ruby_VERSION_MINOR 6) 395 endif() 396 # check whether we found 2.7.x 397 if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?7") 398 set(Ruby_VERSION_MAJOR 2) 399 set(Ruby_VERSION_MINOR 7) 400 endif() 401endif() 402 403if(Ruby_VERSION_MAJOR) 404 set(Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}") 405 set(_Ruby_VERSION_SHORT "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}") 406 set(_Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}") 407 set(_Ruby_NODOT_VERSION "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}") 408 set(_Ruby_NODOT_VERSION_ZERO_PATCH "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}0") 409endif() 410 411# FIXME: Currently we require both the interpreter and development components to be found 412# in order to use either. See issue #20474. 413find_path(Ruby_INCLUDE_DIR 414 NAMES ruby.h 415 HINTS 416 ${Ruby_HDR_DIR} 417 ${Ruby_ARCH_DIR} 418 /usr/lib/ruby/${_Ruby_VERSION_SHORT}/i586-linux-gnu/ 419) 420 421set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIR}) 422 423# if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir 424if( Ruby_FIND_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_HDR_DIR) 425 find_path(Ruby_CONFIG_INCLUDE_DIR 426 NAMES ruby/config.h config.h 427 HINTS 428 ${Ruby_HDR_DIR}/${Ruby_ARCH} 429 ${Ruby_ARCH_DIR} 430 ${Ruby_ARCHHDR_DIR} 431 ) 432 433 set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIRS} ${Ruby_CONFIG_INCLUDE_DIR} ) 434endif() 435 436 437# Determine the list of possible names for the ruby library 438set(_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}) 439 440if(WIN32) 441 set(_Ruby_POSSIBLE_MSVC_RUNTIMES "msvcrt;vcruntime140;vcruntime140_1") 442 if(MSVC_TOOLSET_VERSION) 443 list(APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr${MSVC_TOOLSET_VERSION}") 444 else() 445 list(APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr") 446 endif() 447 448 set(_Ruby_POSSIBLE_VERSION_SUFFICES "${_Ruby_NODOT_VERSION};${_Ruby_NODOT_VERSION_ZERO_PATCH}") 449 450 set(_Ruby_ARCH_PREFIX "") 451 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 452 set(_Ruby_ARCH_PREFIX "x64-") 453 endif() 454 455 foreach(_Ruby_MSVC_RUNTIME ${_Ruby_POSSIBLE_MSVC_RUNTIMES}) 456 foreach(_Ruby_VERSION_SUFFIX ${_Ruby_POSSIBLE_VERSION_SUFFICES}) 457 list(APPEND _Ruby_POSSIBLE_LIB_NAMES 458 "${_Ruby_ARCH_PREFIX}${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}" 459 "${_Ruby_ARCH_PREFIX}${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}-static") 460 endforeach() 461 endforeach() 462endif() 463 464find_library(Ruby_LIBRARY NAMES ${_Ruby_POSSIBLE_LIB_NAMES} HINTS ${Ruby_POSSIBLE_LIB_DIR} ) 465 466set(_Ruby_REQUIRED_VARS Ruby_EXECUTABLE Ruby_INCLUDE_DIR Ruby_LIBRARY) 467if(_Ruby_VERSION_SHORT_NODOT GREATER 18) 468 list(APPEND _Ruby_REQUIRED_VARS Ruby_CONFIG_INCLUDE_DIR) 469endif() 470 471if(_Ruby_DEBUG_OUTPUT) 472 message(STATUS "--------FindRuby.cmake debug------------") 473 message(STATUS "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}") 474 message(STATUS "_Ruby_POSSIBLE_LIB_NAMES: ${_Ruby_POSSIBLE_LIB_NAMES}") 475 message(STATUS "Ruby_ARCH_DIR: ${Ruby_ARCH_DIR}") 476 message(STATUS "Ruby_HDR_DIR: ${Ruby_HDR_DIR}") 477 message(STATUS "Ruby_POSSIBLE_LIB_DIR: ${Ruby_POSSIBLE_LIB_DIR}") 478 message(STATUS "Found Ruby_VERSION: \"${Ruby_VERSION}\" , short: \"${_Ruby_VERSION_SHORT}\", nodot: \"${_Ruby_VERSION_SHORT_NODOT}\"") 479 message(STATUS "_Ruby_REQUIRED_VARS: ${_Ruby_REQUIRED_VARS}") 480 message(STATUS "Ruby_EXECUTABLE: ${Ruby_EXECUTABLE}") 481 message(STATUS "Ruby_LIBRARY: ${Ruby_LIBRARY}") 482 message(STATUS "Ruby_INCLUDE_DIR: ${Ruby_INCLUDE_DIR}") 483 message(STATUS "Ruby_CONFIG_INCLUDE_DIR: ${Ruby_CONFIG_INCLUDE_DIR}") 484 message(STATUS "--------------------") 485endif() 486 487include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) 488FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_Ruby_REQUIRED_VARS} 489 VERSION_VAR Ruby_VERSION ) 490 491if(Ruby_FOUND) 492 set(Ruby_LIBRARIES ${Ruby_LIBRARY}) 493endif() 494 495mark_as_advanced( 496 Ruby_EXECUTABLE 497 Ruby_LIBRARY 498 Ruby_INCLUDE_DIR 499 Ruby_CONFIG_INCLUDE_DIR 500 ) 501 502# Set some variables for compatibility with previous version of this file (no need to provide a CamelCase version of that...) 503set(RUBY_POSSIBLE_LIB_PATH ${Ruby_POSSIBLE_LIB_DIR}) 504set(RUBY_RUBY_LIB_PATH ${Ruby_RUBY_LIB_DIR}) 505set(RUBY_INCLUDE_PATH ${Ruby_INCLUDE_DIRS}) 506 507# Backwards compatibility 508# Define upper case versions of output variables 509foreach(Camel 510 Ruby_EXECUTABLE 511 Ruby_INCLUDE_DIRS 512 Ruby_LIBRARY 513 Ruby_VERSION 514 Ruby_VERSION_MAJOR 515 Ruby_VERSION_MINOR 516 Ruby_VERSION_PATCH 517 518 Ruby_ARCH_DIR 519 Ruby_ARCH 520 Ruby_HDR_DIR 521 Ruby_ARCHHDR_DIR 522 Ruby_POSSIBLE_LIB_DIR 523 Ruby_RUBY_LIB_DIR 524 Ruby_SITEARCH_DIR 525 Ruby_SITELIB_DIR 526 Ruby_HAS_VENDOR_RUBY 527 Ruby_VENDORARCH_DIR 528 Ruby_VENDORLIB_DIR 529 530 ) 531 string(TOUPPER ${Camel} UPPER) 532 set(${UPPER} ${${Camel}}) 533endforeach() 534