Logo AND Algorithmique Numérique Distribuée

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