Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics.
[simgrid.git] / buildtools / Cmake / Modules / FindLua51Simgrid.cmake
1 find_path(HAVE_LUA_H lua.h
2     HINTS
3     $ENV{LD_LIBRARY_PATH}
4     PATH_SUFFIXES lua/ lua/5.1/ include/ include/lua5.1/ include/lua51 include/lua
5     PATHS
6     /opt
7     /opt/local
8     /opt/csw
9     /sw
10     /usr
11 )
12
13 find_library(HAVE_LUA51_LIB
14     NAME lua.5.1 lua5.1 lua51 lua-5.1
15     HINTS
16     $ENV{LD_LIBRARY_PATH}
17     PATH_SUFFIXES lib64 lib
18     PATHS
19     /opt
20     /opt/local
21     /opt/csw
22     /sw
23     /usr
24 )
25
26 find_program(HAVE_LUA_BIN NAMES lua)
27
28 set(LIB_LUA_NAME ${HAVE_LUA51_LIB})
29 string(REGEX MATCH "liblua.*$" LIB_LUA_NAME "${LIB_LUA_NAME}")
30 string(REPLACE ".${LIB_EXE}" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
31 string(REPLACE "lib" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
32
33 if(HAVE_LUA_H AND HAVE_LUA51_LIB AND LIB_LUA_NAME AND HAVE_LUA_BIN)
34  set(LUA51_FOUND 1)
35  string(REPLACE "/lua.h" "" LUA_INCLUDE_DIR ${HAVE_LUA_H})
36  string(REPLACE "/lib${LIB_LUA_NAME}.${LIB_EXE}" "" LUA_LIBRARY_DIR ${HAVE_LUA51_LIB})
37 endif(HAVE_LUA_H AND HAVE_LUA51_LIB AND LIB_LUA_NAME AND HAVE_LUA_BIN)
38
39 set(LUA_CPATH "$ENV{LUA_CPATH}")
40 string(REGEX MATCH "${LIB_EXE}" LUA_CPATH "${LUA_CPATH}")
41
42 if(LUA_CPATH AND APPLE)
43     message("-- LUA_CPATH have extension ${LIB_EXE}")
44 else(DEFINED LUA_CPATH AND APPLE)
45         if(APPLE)
46     message("-- Please set LUA_CPATH with extension ${LIB_EXE}")
47     message("-- For example, execute command line : export LUA_CPATH=\"./?.${LIB_EXE}\"")
48     endif(APPLE)
49 endif(LUA_CPATH AND APPLE)
50
51 mark_as_advanced(LUA_LIB_PATH_1)                                                                                                                      
52 mark_as_advanced(LUA_LIB_PATH_2)
53 mark_as_advanced(LUA_LIB_PATH_3)
54 mark_as_advanced(HAVE_LUA5_1_LAUXLIB_H)                        
55 mark_as_advanced(HAVE_LUA5_1_LUALIB_H)
56 mark_as_advanced(HAVE_LUA51_LIB)                                                                                                                                                                             
57 mark_as_advanced(HAVE_LUA_H)
58 mark_as_advanced(HAVE_LUA_BIN)
59
60 message("-- Looking for lua.h")
61 if(HAVE_LUA_H)
62 message("-- Looking for lua.h - found")
63 else(HAVE_LUA_H)
64 message("-- Looking for lua.h - not found")
65 endif(HAVE_LUA_H)
66
67 message("-- Looking for lib lua")
68 if(HAVE_LUA51_LIB)
69 message("-- Looking for lib lua - found")
70 message("-- Lib lua version: ${LIB_LUA_NAME}")
71 else(HAVE_LUA51_LIB)
72 message("-- Looking for lib lua - not found")
73 endif(HAVE_LUA51_LIB)
74
75 if(HAVE_LUA_BIN)
76 message("-- Found Lua: ${HAVE_LUA_BIN}")
77 endif(HAVE_LUA_BIN)