FindRuby.cmake 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  9. # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  10. if(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
  11. # Already in cache, be silent
  12. set(RUBY_FIND_QUIETLY TRUE)
  13. endif (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
  14. # RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'`
  15. # RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'`
  16. # RUBY_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'`
  17. # RUBY_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'`
  18. # RUBY_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'`
  19. FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby1.8 ruby18 )
  20. EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['archdir']"
  21. OUTPUT_VARIABLE RUBY_ARCH_DIR)
  22. EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['libdir']"
  23. OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH)
  24. EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts Config::CONFIG['rubylibdir']"
  25. OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH)
  26. # remove the new lines from the output by replacing them with empty strings
  27. STRING(REPLACE "\n" "" RUBY_ARCH_DIR "${RUBY_ARCH_DIR}")
  28. STRING(REPLACE "\n" "" RUBY_POSSIBLE_LIB_PATH "${RUBY_POSSIBLE_LIB_PATH}")
  29. STRING(REPLACE "\n" "" RUBY_RUBY_LIB_PATH "${RUBY_RUBY_LIB_PATH}")
  30. FIND_PATH(RUBY_INCLUDE_PATH
  31. NAMES ruby.h
  32. PATHS
  33. ${RUBY_ARCH_DIR}
  34. /usr/lib/ruby/1.8/i586-linux-gnu/ )
  35. FIND_LIBRARY(RUBY_LIBRARY
  36. NAMES ruby ruby1.8
  37. PATHS ${RUBY_POSSIBLE_LIB_PATH}
  38. )
  39. MARK_AS_ADVANCED(
  40. RUBY_EXECUTABLE
  41. RUBY_LIBRARY
  42. RUBY_INCLUDE_PATH
  43. )