1
# Copyright (c) 2003-2009 FlashCode <flashcode@flashtux.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
# This module finds if Ruby is installed and determines where the include files
19
# and libraries are. It also determines what the name of the library is. This
20
# code sets the following variables:
22
# RUBY_EXECUTABLE = full path to the ruby binary
23
# RUBY_INCLUDE_PATH = path to where ruby.h can be found
24
# RUBY_LIBRARY = path to where libruby.so* can be found
27
# Already in cache, be silent
28
SET(RUBY_FIND_QUIETLY TRUE)
31
FIND_PROGRAM(RUBY_EXECUTABLE
32
NAMES ruby ruby1.9 ruby19 ruby1.8 ruby18 ruby1.6 ruby16
33
PATHS /usr/bin /usr/local/bin /usr/pkg/bin
38
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['archdir']"
39
OUTPUT_VARIABLE RUBY_ARCH_DIR
43
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['libdir']"
44
OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH
48
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['rubylibdir']"
49
OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH
52
# remove the new lines from the output by replacing them with empty strings
53
STRING(REPLACE "\n" "" RUBY_ARCH_DIR "${RUBY_ARCH_DIR}")
54
STRING(REPLACE "\n" "" RUBY_POSSIBLE_LIB_PATH "${RUBY_POSSIBLE_LIB_PATH}")
55
STRING(REPLACE "\n" "" RUBY_RUBY_LIB_PATH "${RUBY_RUBY_LIB_PATH}")
57
FIND_PATH(RUBY_INCLUDE_PATH
59
PATHS ${RUBY_ARCH_DIR}
62
FIND_LIBRARY(RUBY_LIBRARY
63
NAMES ruby ruby1.6 ruby16 ruby1.8 ruby18 ruby1.9 ruby19
64
PATHS ${RUBY_POSSIBLE_LIB_PATH} ${RUBY_RUBY_LIB_PATH}
67
IF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
69
ENDIF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
77
ENDIF(RUBY_EXECUTABLE)