FindRuby.cmake 16 KB

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