Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use {include,link}_directories for Find{F2C,Graphviz,Lua51} too.
[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 lua
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 mark_as_advanced(LUA_LIB_PATH_1)                                                                                                                      
40 mark_as_advanced(LUA_LIB_PATH_2)
41 mark_as_advanced(LUA_LIB_PATH_3)
42 mark_as_advanced(HAVE_LUA5_1_LAUXLIB_H)                        
43 mark_as_advanced(HAVE_LUA5_1_LUALIB_H)
44 mark_as_advanced(HAVE_LUA51_LIB)                                                                                                                                                                             
45 mark_as_advanced(HAVE_LUA_H)
46 mark_as_advanced(HAVE_LUA_BIN)
47
48 message(STATUS "Looking for lua.h")
49 if(HAVE_LUA_H)
50 message(STATUS "Looking for lua.h - found")
51 else(HAVE_LUA_H)
52 message(STATUS "Looking for lua.h - not found")
53 endif(HAVE_LUA_H)
54
55 message(STATUS "Looking for lib lua")
56 if(HAVE_LUA51_LIB)
57 message(STATUS "Looking for lib lua - found")
58 message(STATUS "Lib lua version: ${LIB_LUA_NAME}")
59 else(HAVE_LUA51_LIB)
60 message(STATUS "Looking for lib lua - not found")
61 endif(HAVE_LUA51_LIB)
62
63 if(HAVE_LUA_BIN)
64 message(STATUS "Found Lua: ${HAVE_LUA_BIN}")
65 endif(HAVE_LUA_BIN)
66
67 if(LUA51_FOUND)
68   set(HAVE_LUA 1)
69   include_directories(${LUA_INCLUDE_DIR})
70   link_directories(${LUA_LIBRARY_DIR})
71 else(LUA51_FOUND)
72         message(STATUS "Warning : Lua need version 5.1")
73 endif(LUA51_FOUND)