FindRuby.cmake 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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 name of possible executables, ignoring the minor
  102. # Eg:
  103. # 3.2.6 => from ruby34 to ruby32 included
  104. # 3.2 => from ruby34 to ruby32 included
  105. # 3 => from ruby34 to ruby30 included
  106. # empty => from ruby34 to ruby18 included
  107. if(NOT Ruby_FIND_VERSION_EXACT)
  108. foreach(_ruby_version RANGE 34 18 -1)
  109. string(SUBSTRING "${_ruby_version}" 0 1 _ruby_major_version)
  110. string(SUBSTRING "${_ruby_version}" 1 1 _ruby_minor_version)
  111. # Append both rubyX.Y and rubyXY (eg: ruby2.7 ruby27)
  112. list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby${_ruby_major_version}.${_ruby_minor_version} ruby${_ruby_major_version}${_ruby_minor_version})
  113. endforeach()
  114. endif()
  115. # Virtual environment handling
  116. if (DEFINED Ruby_FIND_VIRTUALENV AND NOT Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$")
  117. message (AUTHOR_WARNING "FindRuby: ${Ruby_FIND_VIRTUALENV}: invalid value for 'Ruby_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.")
  118. set (Ruby_FIND_VIRTUALENV "FIRST")
  119. elseif (NOT DEFINED Ruby_FIND_VIRTUALENV)
  120. # Default is to search for virtual environments first
  121. set (Ruby_FIND_VIRTUALENV "FIRST")
  122. endif()
  123. function (_RUBY_VALIDATE_INTERPRETER)
  124. if (NOT Ruby_EXECUTABLE)
  125. return()
  126. endif()
  127. cmake_parse_arguments (PARSE_ARGV 0 _RVI "EXACT;CHECK_EXISTS" "" "")
  128. if (_RVI_UNPARSED_ARGUMENTS)
  129. set (expected_version ${_RVI_UNPARSED_ARGUMENTS})
  130. else()
  131. unset (expected_version)
  132. endif()
  133. if (_RVI_CHECK_EXISTS AND NOT EXISTS "${Ruby_EXECUTABLE}")
  134. # interpreter does not exist anymore
  135. set (_Ruby_Interpreter_REASON_FAILURE "Cannot find the interpreter \"${Ruby_EXECUTABLE}\"")
  136. set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND")
  137. return()
  138. endif()
  139. # Check the version it returns
  140. # executable found must have a specific version
  141. execute_process (COMMAND "${Ruby_EXECUTABLE}" -e "puts RUBY_VERSION"
  142. RESULT_VARIABLE result
  143. OUTPUT_VARIABLE version
  144. ERROR_QUIET
  145. OUTPUT_STRIP_TRAILING_WHITESPACE)
  146. if (result OR (_RVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version))
  147. # interpreter not usable or has wrong major version
  148. if (result)
  149. set (_Ruby_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${Ruby_EXECUTABLE}\"")
  150. else()
  151. set (_Ruby_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${Ruby_EXECUTABLE}\"")
  152. endif()
  153. set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND")
  154. return()
  155. endif()
  156. endfunction()
  157. function(_RUBY_CONFIG_VAR RBVAR OUTVAR)
  158. execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']"
  159. RESULT_VARIABLE _Ruby_SUCCESS
  160. OUTPUT_VARIABLE _Ruby_OUTPUT
  161. ERROR_QUIET)
  162. if(_Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "")
  163. execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
  164. RESULT_VARIABLE _Ruby_SUCCESS
  165. OUTPUT_VARIABLE _Ruby_OUTPUT
  166. ERROR_QUIET)
  167. endif()
  168. set(${OUTVAR} "${_Ruby_OUTPUT}" PARENT_SCOPE)
  169. endfunction()
  170. #### Check RVM virtual environment ###
  171. function (_RUBY_CHECK_RVM)
  172. if (NOT DEFINED ENV{MY_RUBY_HOME})
  173. return()
  174. endif()
  175. find_program (Ruby_EXECUTABLE
  176. NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}
  177. NAMES_PER_DIR
  178. PATHS ENV MY_RUBY_HOME
  179. PATH_SUFFIXES bin Scripts
  180. NO_CMAKE_PATH
  181. NO_CMAKE_ENVIRONMENT_PATH
  182. NO_SYSTEM_ENVIRONMENT_PATH
  183. NO_CMAKE_SYSTEM_PATH)
  184. _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}})
  185. if(Ruby_EXECUTABLE)
  186. set(Ruby_ENV "RVM" CACHE INTERNAL "Ruby environment")
  187. endif()
  188. endfunction()
  189. #### Check system installed Ruby ###
  190. function (_RUBY_CHECK_SYSTEM)
  191. find_program (Ruby_EXECUTABLE
  192. NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}
  193. NAMES_PER_DIR)
  194. _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION})
  195. if(Ruby_EXECUTABLE)
  196. set(Ruby_ENV "Standard" CACHE INTERNAL "Ruby environment")
  197. endif()
  198. endfunction()
  199. # Find Ruby
  200. if(NOT Ruby_EXECUTABLE AND Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
  201. _RUBY_CHECK_RVM()
  202. endif()
  203. # Check for system installed Ruby
  204. if(NOT Ruby_EXECUTABLE AND NOT Ruby_FIND_VIRTUALENV STREQUAL "ONLY")
  205. _RUBY_CHECK_SYSTEM()
  206. endif()
  207. if(Ruby_EXECUTABLE AND NOT Ruby_EXECUTABLE STREQUAL "${_Ruby_EXECUTABLE_LAST_QUERIED}")
  208. # query the ruby version
  209. _RUBY_CONFIG_VAR("MAJOR" Ruby_VERSION_MAJOR)
  210. _RUBY_CONFIG_VAR("MINOR" Ruby_VERSION_MINOR)
  211. _RUBY_CONFIG_VAR("TEENY" Ruby_VERSION_PATCH)
  212. # query the different directories
  213. _RUBY_CONFIG_VAR("archdir" Ruby_ARCH_DIR)
  214. _RUBY_CONFIG_VAR("arch" Ruby_ARCH)
  215. _RUBY_CONFIG_VAR("rubyhdrdir" Ruby_HDR_DIR)
  216. _RUBY_CONFIG_VAR("rubyarchhdrdir" Ruby_ARCHHDR_DIR)
  217. _RUBY_CONFIG_VAR("libdir" _Ruby_POSSIBLE_LIB_DIR)
  218. _RUBY_CONFIG_VAR("rubylibdir" Ruby_RUBY_LIB_DIR)
  219. # site_ruby
  220. _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR)
  221. _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR)
  222. # vendor_ruby available ?
  223. execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'"
  224. OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY ERROR_QUIET)
  225. if(Ruby_HAS_VENDOR_RUBY)
  226. _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR)
  227. _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR)
  228. endif()
  229. # save the results in the cache so we don't have to run ruby the next time again
  230. set(_Ruby_EXECUTABLE_LAST_QUERIED "${Ruby_EXECUTABLE}" CACHE INTERNAL "The ruby executable last queried for version and path info")
  231. set(Ruby_VERSION_MAJOR ${Ruby_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE)
  232. set(Ruby_VERSION_MINOR ${Ruby_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE)
  233. set(Ruby_VERSION_PATCH ${Ruby_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE)
  234. set(Ruby_ARCH_DIR ${Ruby_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE)
  235. set(Ruby_HDR_DIR ${Ruby_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE)
  236. set(Ruby_ARCHHDR_DIR ${Ruby_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE)
  237. set(_Ruby_POSSIBLE_LIB_DIR ${_Ruby_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE)
  238. set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE)
  239. set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
  240. set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE)
  241. set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
  242. set(Ruby_VENDORARCH_DIR ${Ruby_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE)
  243. set(Ruby_VENDORLIB_DIR ${Ruby_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE)
  244. mark_as_advanced(
  245. Ruby_ARCH_DIR
  246. Ruby_ARCH
  247. Ruby_HDR_DIR
  248. Ruby_ARCHHDR_DIR
  249. _Ruby_POSSIBLE_LIB_DIR
  250. Ruby_RUBY_LIB_DIR
  251. Ruby_SITEARCH_DIR
  252. Ruby_SITELIB_DIR
  253. Ruby_HAS_VENDOR_RUBY
  254. Ruby_VENDORARCH_DIR
  255. Ruby_VENDORLIB_DIR
  256. Ruby_VERSION_MAJOR
  257. Ruby_VERSION_MINOR
  258. Ruby_VERSION_PATCH
  259. )
  260. endif()
  261. # In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling)
  262. # try to detect which version we found. This is not too good.
  263. if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR)
  264. # by default assume 1.8.0
  265. set(Ruby_VERSION_MAJOR 1)
  266. set(Ruby_VERSION_MINOR 8)
  267. set(Ruby_VERSION_PATCH 0)
  268. # check whether we found 1.9.x
  269. if(${Ruby_EXECUTABLE} MATCHES "ruby1\\.?9")
  270. set(Ruby_VERSION_MAJOR 1)
  271. set(Ruby_VERSION_MINOR 9)
  272. endif()
  273. # check whether we found 2.[0-7].x
  274. if(${Ruby_EXECUTABLE} MATCHES "ruby2")
  275. set(Ruby_VERSION_MAJOR 2)
  276. string(REGEX_REPLACE ${Ruby_EXECUTABLE} "ruby2\\.?([0-7])" "\\1" Ruby_VERSION_MINOR)
  277. endif()
  278. # check whether we found 3.[0-1].x
  279. if(${Ruby_EXECUTABLE} MATCHES "ruby3")
  280. set(Ruby_VERSION_MAJOR 3)
  281. string(REGEX_REPLACE ${Ruby_EXECUTABLE} "ruby3\\.?([0-1])" "\\1" Ruby_VERSION_MINOR)
  282. endif()
  283. endif()
  284. if(Ruby_VERSION_MAJOR)
  285. set(Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}")
  286. set(_Ruby_VERSION_SHORT "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}")
  287. set(_Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}")
  288. set(_Ruby_NODOT_VERSION "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}")
  289. set(_Ruby_NODOT_VERSION_ZERO_PATCH "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}0")
  290. endif()
  291. # FIXME: Currently we require both the interpreter and development components to be found
  292. # in order to use either. See issue #20474.
  293. find_path(Ruby_INCLUDE_DIR
  294. NAMES ruby.h
  295. HINTS
  296. ${Ruby_HDR_DIR}
  297. ${Ruby_ARCH_DIR}
  298. /usr/lib/ruby/${_Ruby_VERSION_SHORT}/i586-linux-gnu/
  299. )
  300. set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIR})
  301. # if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir
  302. if( Ruby_FIND_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_HDR_DIR)
  303. find_path(Ruby_CONFIG_INCLUDE_DIR
  304. NAMES ruby/config.h config.h
  305. HINTS
  306. ${Ruby_HDR_DIR}/${Ruby_ARCH}
  307. ${Ruby_ARCH_DIR}
  308. ${Ruby_ARCHHDR_DIR}
  309. )
  310. set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIRS} ${Ruby_CONFIG_INCLUDE_DIR} )
  311. endif()
  312. # Determine the list of possible names for the ruby library
  313. 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})
  314. if(WIN32)
  315. set(_Ruby_POSSIBLE_MSVC_RUNTIMES "ucrt;msvcrt;vcruntime140;vcruntime140_1")
  316. if(MSVC_TOOLSET_VERSION)
  317. list(APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr${MSVC_TOOLSET_VERSION}")
  318. else()
  319. list(APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr")
  320. endif()
  321. set(_Ruby_POSSIBLE_VERSION_SUFFICES "${_Ruby_NODOT_VERSION};${_Ruby_NODOT_VERSION_ZERO_PATCH}")
  322. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  323. set(_Ruby_POSSIBLE_ARCH_PREFIXS "libx64-;x64-")
  324. else()
  325. set(_Ruby_POSSIBLE_ARCH_PREFIXS "lib")
  326. endif()
  327. foreach(_Ruby_MSVC_RUNTIME ${_Ruby_POSSIBLE_MSVC_RUNTIMES})
  328. foreach(_Ruby_VERSION_SUFFIX ${_Ruby_POSSIBLE_VERSION_SUFFICES})
  329. foreach(_Ruby_ARCH_PREFIX ${_Ruby_POSSIBLE_ARCH_PREFIXS})
  330. list(APPEND _Ruby_POSSIBLE_LIB_NAMES
  331. "${_Ruby_ARCH_PREFIX}${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}"
  332. "${_Ruby_ARCH_PREFIX}${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}-static")
  333. endforeach()
  334. endforeach()
  335. endforeach()
  336. endif()
  337. find_library(Ruby_LIBRARY NAMES ${_Ruby_POSSIBLE_LIB_NAMES} HINTS ${_Ruby_POSSIBLE_LIB_DIR} )
  338. set(_Ruby_REQUIRED_VARS Ruby_EXECUTABLE Ruby_INCLUDE_DIR Ruby_LIBRARY)
  339. if(_Ruby_VERSION_SHORT_NODOT GREATER 18)
  340. list(APPEND _Ruby_REQUIRED_VARS Ruby_CONFIG_INCLUDE_DIR)
  341. endif()
  342. if(_Ruby_DEBUG_OUTPUT)
  343. message(STATUS "--------FindRuby.cmake debug------------")
  344. message(STATUS "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}")
  345. message(STATUS "_Ruby_POSSIBLE_LIB_DIR: ${_Ruby_POSSIBLE_LIB_DIR}")
  346. message(STATUS "_Ruby_POSSIBLE_LIB_NAMES: ${_Ruby_POSSIBLE_LIB_NAMES}")
  347. message(STATUS "Ruby_FIND_VIRTUALENV=${Ruby_FIND_VIRTUALENV}")
  348. message(STATUS "Ruby_ENV: ${Ruby_ENV}")
  349. message(STATUS "Found Ruby_VERSION: \"${Ruby_VERSION}\"")
  350. message(STATUS "Ruby_EXECUTABLE: ${Ruby_EXECUTABLE}")
  351. message(STATUS "Ruby_LIBRARY: ${Ruby_LIBRARY}")
  352. message(STATUS "Ruby_INCLUDE_DIR: ${Ruby_INCLUDE_DIR}")
  353. message(STATUS "Ruby_CONFIG_INCLUDE_DIR: ${Ruby_CONFIG_INCLUDE_DIR}")
  354. message(STATUS "Ruby_HDR_DIR: ${Ruby_HDR_DIR}")
  355. message(STATUS "Ruby_ARCH_DIR: ${Ruby_ARCH_DIR}")
  356. message(STATUS "--------------------")
  357. endif()
  358. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  359. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_Ruby_REQUIRED_VARS}
  360. VERSION_VAR Ruby_VERSION )
  361. if(Ruby_FOUND)
  362. set(Ruby_LIBRARIES ${Ruby_LIBRARY})
  363. endif()
  364. mark_as_advanced(
  365. Ruby_EXECUTABLE
  366. Ruby_LIBRARY
  367. Ruby_INCLUDE_DIR
  368. Ruby_CONFIG_INCLUDE_DIR
  369. )
  370. # Set some variables for compatibility with previous version of this file (no need to provide a CamelCase version of that...)
  371. set(RUBY_POSSIBLE_LIB_PATH ${_Ruby_POSSIBLE_LIB_DIR})
  372. set(RUBY_RUBY_LIB_PATH ${Ruby_RUBY_LIB_DIR})
  373. set(RUBY_INCLUDE_PATH ${Ruby_INCLUDE_DIRS})
  374. # Backwards compatibility
  375. # Define upper case versions of output variables
  376. foreach(Camel
  377. Ruby_EXECUTABLE
  378. Ruby_INCLUDE_DIRS
  379. Ruby_LIBRARY
  380. Ruby_VERSION
  381. Ruby_VERSION_MAJOR
  382. Ruby_VERSION_MINOR
  383. Ruby_VERSION_PATCH
  384. Ruby_ARCH_DIR
  385. Ruby_ARCH
  386. Ruby_HDR_DIR
  387. Ruby_ARCHHDR_DIR
  388. Ruby_RUBY_LIB_DIR
  389. Ruby_SITEARCH_DIR
  390. Ruby_SITELIB_DIR
  391. Ruby_HAS_VENDOR_RUBY
  392. Ruby_VENDORARCH_DIR
  393. Ruby_VENDORLIB_DIR
  394. )
  395. string(TOUPPER ${Camel} UPPER)
  396. set(${UPPER} ${${Camel}})
  397. endforeach()