Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'v3_8_x'
[simgrid.git] / buildtools / Cmake / Modules / FindLua51Simgrid.cmake
1 include(FindLua51)
2 find_program(HAVE_LUA_BIN NAMES lua)
3 mark_as_advanced(HAVE_LUA_BIN)
4
5 message(STATUS "Looking for lua.h")
6 if(LUA_INCLUDE_DIR)
7   message(STATUS "Looking for lua.h - found")
8 else()
9   message(STATUS "Looking for lua.h - not found")
10 endif()
11
12 if(HAVE_LUA_BIN)
13   message(STATUS "Found Lua: ${HAVE_LUA_BIN}")
14 endif()
15
16 set(LIB_LUA_NAME "")
17
18 foreach(lib_path ${LUA_LIBRARIES})
19   if(NOT LIB_LUA_NAME)
20     string(REGEX MATCH "liblua.*$" LIB_LUA_NAME "${lib_path}")
21     string(REPLACE ".${LIB_EXE}" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
22     string(REPLACE "lib" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
23     if(LIB_LUA_NAME)
24       string(REPLACE "/lib${LIB_LUA_NAME}.${LIB_EXE}" "" LUA_LIBRARY_DIR ${lib_path})
25     endif()
26   endif()
27 endforeach(lib_path ${LUA_LIBRARIES})
28
29 message(STATUS "Looking for lib lua")
30 if(LUA_LIBRARY_DIR)
31   message(STATUS "Looking for lib lua - found")
32   message(STATUS "Lua version: ${LIB_LUA_NAME}")
33   message(STATUS "Lib path   : ${LUA_LIBRARY_DIR}")
34 else()
35   message(STATUS "Looking for lib lua - not found")
36 endif()
37
38 if(LUA51_FOUND)
39   set(HAVE_LUA 1)
40   include_directories(${LUA_INCLUDE_DIR})
41   link_directories(${LUA_LIBRARY_DIR})
42 else()
43   message(STATUS "Warning : Lua need version 5.1")
44 endif()