FindRuby: clean up querying variables from Ruby
Newer Ruby versions (from 1.9 onward) seem to warn if you query Config::CONFIG and print a warning to use RbConfig instead. RbConfig seems to also work in older versions, at least in 1.8. Use a macro to query RbConfig first and only if that doesn't give anything fall back to Config.
This commit is contained in:
parent
d03606a19c
commit
854e76237c
|
@ -61,49 +61,44 @@ FIND_PROGRAM(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
|
|||
|
||||
|
||||
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}']"
|
||||
RESULT_VARIABLE _RUBY_SUCCESS
|
||||
OUTPUT_VARIABLE _RUBY_OUTPUT
|
||||
ERROR_QUIET)
|
||||
IF(_RUBY_SUCCESS OR NOT _RUBY_OUTPUT)
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
|
||||
RESULT_VARIABLE _RUBY_SUCCESS
|
||||
OUTPUT_VARIABLE _RUBY_OUTPUT
|
||||
ERROR_QUIET)
|
||||
ENDIF(_RUBY_SUCCESS OR NOT _RUBY_OUTPUT)
|
||||
SET(${OUTVAR} "${_RUBY_OUTPUT}" PARENT_SCOPE)
|
||||
ENDFUNCTION(_RUBY_CONFIG_VAR)
|
||||
|
||||
|
||||
# query the ruby version
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['MAJOR']"
|
||||
OUTPUT_VARIABLE RUBY_VERSION_MAJOR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['MINOR']"
|
||||
OUTPUT_VARIABLE RUBY_VERSION_MINOR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['TEENY']"
|
||||
OUTPUT_VARIABLE RUBY_VERSION_PATCH)
|
||||
_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
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['archdir']"
|
||||
OUTPUT_VARIABLE RUBY_ARCH_DIR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['arch']"
|
||||
OUTPUT_VARIABLE RUBY_ARCH)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['rubyhdrdir']"
|
||||
OUTPUT_VARIABLE RUBY_HDR_DIR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['libdir']"
|
||||
OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_DIR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['rubylibdir']"
|
||||
OUTPUT_VARIABLE RUBY_RUBY_LIB_DIR)
|
||||
_RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR)
|
||||
_RUBY_CONFIG_VAR("arch" RUBY_ARCH)
|
||||
_RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR)
|
||||
_RUBY_CONFIG_VAR("libdir" RUBY_POSSIBLE_LIB_DIR)
|
||||
_RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR)
|
||||
|
||||
# site_ruby
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
|
||||
OUTPUT_VARIABLE RUBY_SITEARCH_DIR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
|
||||
OUTPUT_VARIABLE RUBY_SITELIB_DIR)
|
||||
_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'"
|
||||
OUTPUT_VARIABLE RUBY_HAS_VENDOR_RUBY ERROR_QUIET)
|
||||
|
||||
IF(RUBY_HAS_VENDOR_RUBY)
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']"
|
||||
OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']"
|
||||
OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
|
||||
_RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR)
|
||||
_RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR)
|
||||
ENDIF(RUBY_HAS_VENDOR_RUBY)
|
||||
|
||||
# save the results in the cache so we don't have to run ruby the next time again
|
||||
|
|
Loading…
Reference in New Issue