2 # This module finds if Ruby is installed and determines where the include files
3 # and libraries are. It also determines what the name of the library is. This
4 # code sets the following variables:
6 # RUBY_INCLUDE_PATH = path to where ruby.h can be found
7 # RUBY_EXECUTABLE = full path to the ruby binary
9 # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
13 if(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
14 # Already in cache, be silent
15 set(RUBY_FIND_QUIETLY TRUE)
16 endif (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
18 # RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'`
19 # RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'`
20 # RUBY_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'`
21 # RUBY_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'`
22 # RUBY_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'`
24 FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby1.8 ruby18 )
26 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['archdir']"
27 OUTPUT_VARIABLE RUBY_ARCH_DIR)
29 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['libdir']"
30 OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH)
32 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['rubylibdir']"
33 OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH)
36 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
37 OUTPUT_VARIABLE RUBY_SITEARCH_DIR)
39 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
40 OUTPUT_VARIABLE RUBY_SITELIB_DIR)
44 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print '-rvendor-specific'"
45 OUTPUT_VARIABLE RUBY_VENDOR_ARG)
48 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']"
49 OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
51 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']"
52 OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
54 # fall back to site*dir
55 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
56 OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
58 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
59 OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
60 ENDIF(RUBY_VENDOR_ARG)
62 # this is not needed if you use "print" inside the ruby statements
63 # remove the new lines from the output by replacing them with empty strings
64 #STRING(REPLACE "\n" "" RUBY_ARCH_DIR "${RUBY_ARCH_DIR}")
65 #STRING(REPLACE "\n" "" RUBY_POSSIBLE_LIB_PATH "${RUBY_POSSIBLE_LIB_PATH}")
66 #STRING(REPLACE "\n" "" RUBY_RUBY_LIB_PATH "${RUBY_RUBY_LIB_PATH}")
69 FIND_PATH(RUBY_INCLUDE_PATH
73 /usr/lib/ruby/1.8/i586-linux-gnu/ )
75 FIND_LIBRARY(RUBY_LIBRARY
77 PATHS ${RUBY_POSSIBLE_LIB_PATH}