Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[cmake] try harder to find a dynamic lib for lua
[simgrid.git] / tools / cmake / Modules / FindRubySimgrid.cmake
1 include(FindRuby)
2
3 if(RUBY_EXECUTABLE)
4   message(STATUS "Found ruby:   ${RUBY_EXECUTABLE}")
5 endif()
6
7 message(STATUS "Looking for ruby.h")
8 if(RUBY_INCLUDE_DIR)
9   message(STATUS "Looking for ruby.h - found")
10 else()
11   message(STATUS "Looking for ruby.h - not found")
12 endif()
13
14 message(STATUS "Looking for confi.h")
15 if(RUBY_CONFIG_INCLUDE_DIR)
16   message(STATUS "Looking for config.h - found")
17 else()
18   message(STATUS "Looking for config.h - not found")
19 endif()
20
21 message(STATUS "Looking for lib ruby")
22 if(RUBY_LIBRARY)
23   message(STATUS "Looking for lib ruby - found")
24 else()
25   message(STATUS "Looking for lib ruby - not found")
26 endif()
27
28 if(RUBY_LIBRARY)
29   set(LIB_RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}")
30   message(STATUS "Lib ruby version: ${LIB_RUBY_VERSION}")
31   if(RUBY_VERSION_MAJOR MATCHES "1" AND RUBY_VERSION_MINOR MATCHES "9")
32     string(REGEX MATCH "ruby.*[0-9]" RUBY_LIBRARY_NAME ${RUBY_LIBRARY})
33     if(NOT RUBY_LIBRARY_NAME)
34       set(RUBY_LIBRARY_NAME ruby)
35     endif()
36     string(REGEX REPLACE "/libruby.*$" "" RUBY_LIBRARY ${RUBY_LIBRARY})
37     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${RUBY_CONFIG_INCLUDE_DIR} ") #path to config.h
38     string(COMPARE EQUAL "${RUBY_INCLUDE_DIR}" "${RUBY_CONFIG_INCLUDE_DIR}" operation)
39     if(NOT operation)
40       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${RUBY_INCLUDE_DIR} ") #path to ruby.h
41     endif()
42     ADD_DEFINITIONS("-I${CMAKE_HOME_DIRECTORY}/src/bindings/ruby -I${CMAKE_HOME_DIRECTORY}/src/simix")
43     SET(HAVE_RUBY 1)
44   else()
45     message(STATUS "Warning: Ruby bindings need version 1.9.x, but found version ${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.x")
46     SET(HAVE_RUBY 0)
47   endif()
48 else()
49   SET(HAVE_RUBY 0)
50 endif()
51
52 if(NOT RUBY_EXECUTABLE)
53   message(STATUS "Warning: you are missing the ruby executable, so you can compile and build examples but can't execute them!")
54 endif()