~ubuntu-branches/ubuntu/trusty/weechat/trusty-proposed

« back to all changes in this revision

Viewing changes to cmake/FindRuby.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Emmanuel Bouthenot
  • Date: 2009-09-15 20:58:07 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090915205807-nd2nx3kof2aldqbt
Tags: 0.3.0-1
* New (final) upstream release.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2003-2009 FlashCode <flashcode@flashtux.org>
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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/>.
 
15
#
 
16
 
 
17
# - Find Ruby
 
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:
 
21
#
 
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
 
25
 
 
26
IF(RUBY_FOUND)
 
27
   # Already in cache, be silent
 
28
   SET(RUBY_FIND_QUIETLY TRUE)
 
29
ENDIF(RUBY_FOUND)
 
30
 
 
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
 
34
  )
 
35
 
 
36
IF(RUBY_EXECUTABLE)
 
37
  EXECUTE_PROCESS(
 
38
    COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['archdir']"
 
39
    OUTPUT_VARIABLE RUBY_ARCH_DIR
 
40
    )
 
41
 
 
42
  EXECUTE_PROCESS(
 
43
    COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['libdir']"
 
44
    OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH
 
45
    )
 
46
  
 
47
  EXECUTE_PROCESS(
 
48
    COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['rubylibdir']"
 
49
    OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH
 
50
    )
 
51
  
 
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}")
 
56
  
 
57
  FIND_PATH(RUBY_INCLUDE_PATH
 
58
    NAMES ruby.h
 
59
    PATHS ${RUBY_ARCH_DIR}
 
60
    )
 
61
 
 
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}
 
65
    )
 
66
 
 
67
  IF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
 
68
    SET(RUBY_FOUND TRUE)
 
69
  ENDIF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
 
70
 
 
71
  MARK_AS_ADVANCED(
 
72
    RUBY_EXECUTABLE
 
73
    RUBY_LIBRARY
 
74
    RUBY_INCLUDE_PATH
 
75
    )
 
76
  
 
77
ENDIF(RUBY_EXECUTABLE)