Merge topic 'improve-findruby'

854e762 FindRuby: clean up querying variables from Ruby
This commit is contained in:
David Cole 2012-02-21 15:55:26 -05:00 committed by CMake Topic Stage
commit 7023f610d4
1 changed files with 27 additions and 32 deletions

View File

@ -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