]> icculus.org git repositories - duncan/yast2-ruby-bindings.git/blob - cmake/modules/FindRuby.cmake
- Lot of fixes and support for the UI!!!
[duncan/yast2-ruby-bindings.git] / cmake / modules / FindRuby.cmake
1 # - Find Ruby
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:
5 #
6 #  RUBY_INCLUDE_PATH = path to where ruby.h can be found
7 #  RUBY_EXECUTABLE   = full path to the ruby binary
8
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.
11
12
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)
17
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"@:>@)'`
23
24 FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby1.8 ruby18 )
25
26 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['archdir']"
27    OUTPUT_VARIABLE RUBY_ARCH_DIR)
28
29 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['libdir']"
30    OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH)
31
32 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['rubylibdir']"
33    OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH)
34
35 # site_ruby
36 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
37    OUTPUT_VARIABLE RUBY_SITEARCH_DIR)
38
39 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
40    OUTPUT_VARIABLE RUBY_SITELIB_DIR)
41
42
43 # vendor_ruby
44 EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print '-rvendor-specific'"
45    OUTPUT_VARIABLE RUBY_VENDOR_ARG)
46
47 IF(RUBY_VENDOR_ARG)
48     EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']"
49        OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
50
51     EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']"
52        OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
53 ELSE(RUBY_VENDOR_ARG)
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)
57
58     EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
59        OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
60 ENDIF(RUBY_VENDOR_ARG)
61
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}")
67
68
69 FIND_PATH(RUBY_INCLUDE_PATH
70    NAMES ruby.h
71   PATHS
72    ${RUBY_ARCH_DIR}
73   /usr/lib/ruby/1.8/i586-linux-gnu/ )
74
75 FIND_LIBRARY(RUBY_LIBRARY
76   NAMES ruby ruby1.8
77   PATHS ${RUBY_POSSIBLE_LIB_PATH}
78   )
79
80 MARK_AS_ADVANCED(
81   RUBY_EXECUTABLE
82   RUBY_LIBRARY
83   RUBY_INCLUDE_PATH
84   )