Merge topic 'FindRuby-2'

57abfeaa Help: Add FindRuby-2 topic release notes
165f6430 FindRuby: Add support for Ruby 2.0 and 2.1
This commit is contained in:
Brad King 2014-03-03 10:06:24 -05:00 committed by CMake Topic Stage
commit d57bc8797d
2 changed files with 24 additions and 4 deletions

View File

@ -0,0 +1,4 @@
FindRuby-2
----------
* The :module:`FindRuby` module learned to search for Ruby 2.0 and 2.1.

View File

@ -5,7 +5,8 @@
# Find Ruby # Find Ruby
# #
# This module finds if Ruby is installed and determines where the # This module finds if Ruby is installed and determines where the
# include files and libraries are. Ruby 1.8 and 1.9 are supported. # include files and libraries are. Ruby 1.8, 1.9, 2.0 and 2.1 are
# supported.
# #
# The minimum required version of Ruby can be specified using the # The minimum required version of Ruby can be specified using the
# standard syntax, e.g. find_package(Ruby 1.8) # standard syntax, e.g. find_package(Ruby 1.8)
@ -67,6 +68,8 @@ else()
endif() endif()
if(NOT Ruby_FIND_VERSION_EXACT) if(NOT Ruby_FIND_VERSION_EXACT)
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.1 ruby21)
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.0 ruby20)
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19) list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19)
# if we want a version below 1.9, also look for ruby 1.8 # if we want a version below 1.9, also look for ruby 1.8
@ -79,7 +82,6 @@ endif()
find_program(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}) find_program(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR) if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
function(_RUBY_CONFIG_VAR RBVAR OUTVAR) function(_RUBY_CONFIG_VAR RBVAR OUTVAR)
execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']" execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']"
@ -105,6 +107,7 @@ if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
_RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR) _RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR)
_RUBY_CONFIG_VAR("arch" RUBY_ARCH) _RUBY_CONFIG_VAR("arch" RUBY_ARCH)
_RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR) _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("libdir" RUBY_POSSIBLE_LIB_DIR)
_RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR) _RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR)
@ -126,7 +129,8 @@ if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
set(RUBY_VERSION_MINOR ${RUBY_VERSION_MINOR} CACHE PATH "The Ruby minor 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_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_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_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_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_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_SITEARCH_DIR ${RUBY_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
@ -139,6 +143,7 @@ if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
RUBY_ARCH_DIR RUBY_ARCH_DIR
RUBY_ARCH RUBY_ARCH
RUBY_HDR_DIR RUBY_HDR_DIR
RUBY_ARCHHDR_DIR
RUBY_POSSIBLE_LIB_DIR RUBY_POSSIBLE_LIB_DIR
RUBY_RUBY_LIB_DIR RUBY_RUBY_LIB_DIR
RUBY_SITEARCH_DIR RUBY_SITEARCH_DIR
@ -160,10 +165,20 @@ if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
set(RUBY_VERSION_MINOR 8) set(RUBY_VERSION_MINOR 8)
set(RUBY_VERSION_PATCH 0) set(RUBY_VERSION_PATCH 0)
# check whether we found 1.9.x # check whether we found 1.9.x
if(${RUBY_EXECUTABLE} MATCHES "ruby1.?9" OR RUBY_HDR_DIR) if(${RUBY_EXECUTABLE} MATCHES "ruby1.?9")
set(RUBY_VERSION_MAJOR 1) set(RUBY_VERSION_MAJOR 1)
set(RUBY_VERSION_MINOR 9) set(RUBY_VERSION_MINOR 9)
endif() endif()
# check whether we found 2.0.x
if(${RUBY_EXECUTABLE} MATCHES "ruby2.?0")
set(RUBY_VERSION_MAJOR 2)
set(RUBY_VERSION_MINOR 0)
endif()
# check whether we found 2.1.x
if(${RUBY_EXECUTABLE} MATCHES "ruby2.?1")
set(RUBY_VERSION_MAJOR 2)
set(RUBY_VERSION_MINOR 1)
endif()
endif() endif()
if(RUBY_VERSION_MAJOR) if(RUBY_VERSION_MAJOR)
@ -189,6 +204,7 @@ if( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_RUBY_VERSION_SHORT_NO
HINTS HINTS
${RUBY_HDR_DIR}/${RUBY_ARCH} ${RUBY_HDR_DIR}/${RUBY_ARCH}
${RUBY_ARCH_DIR} ${RUBY_ARCH_DIR}
${RUBY_ARCHHDR_DIR}
) )
set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} ) set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} )