summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/FindRuby.cmake57
1 files changed, 26 insertions, 31 deletions
diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake
index c4adfd1..5e973e4 100644
--- a/Modules/FindRuby.cmake
+++ b/Modules/FindRuby.cmake
@@ -61,49 +61,44 @@ FIND_PROGRAM(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
IF(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
- # query the ruby version
- EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['MAJOR']"
- OUTPUT_VARIABLE 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)
- 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)
+ # query the ruby version
+ _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