Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/FindLua.cmake @ 2319

Last change on this file since 2319 was 1776, checked in by landauf, 16 years ago

Many changes in almost all FindXYZ.cmake files. They now throw errors if something wasn't found.

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1#  Find Lua header and library files
2#
3#  When called, this script tries to define:
4#  Lua_INCLUDE_DIR    Header files directory
5#  Lua_LIBRARIES      library files (or file when using lua 5.1)
6#  Lua_FOUND          defined (true) if lua was found
7#  Lua_VERSION        either 5.1 or 5.0 or undefined
8#
9#  authors: Benjamin Knecht, Reto Grieder
10#
11# Several changes and additions by Fabian 'x3n' Landau
12#                 > www.orxonox.net <
13
14IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
15
16  # Already in cache, be silent
17  SET(Lua_FOUND TRUE)
18  SET(Lua_FIND_QUIETLY TRUE) 
19#  MESSAGE(STATUS "Lua was found.")
20
21ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
22
23  FIND_PATH(Lua_INCLUDE_DIR_51 lua.h
24    /usr/include/lua5.1
25    /usr/local/include/lua5.1
26    ../libs/lua-5.1.3/include)
27
28  FIND_PATH(Lua_INCLUDE_DIR_50 lua.h
29    /usr/include/lua50
30    /usr/local/include/lua50
31    /usr/pack/lua-5.0.3-sd/include)
32
33  FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS
34    /usr/lib
35    /usr/local/lib
36    ../libs/lua-5.1.3/lib)
37
38  FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS
39    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
40    /usr/lib
41    /usr/local/lib)
42
43  FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS
44    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
45    /usr/lib
46    /usr/local/lib)
47
48
49  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
50
51    # Found newer lua 5.1 libs
52    SET(Lua_FOUND TRUE)
53    SET(Lua_VERSION "5.1" CACHE STRING "")
54    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "")
55    SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "")
56    SET(Lua_LIBRARY_NAMES "lua5.1 lua")
57
58  ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
59
60    # Found older lua 5.0 libs
61    SET(Lua_FOUND TRUE)
62    SET(Lua_VERSION "5.0" CACHE STRING "")
63    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "")
64    SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "")
65    SET(Lua_LIBRARY_NAMES "lua50 lua, lualib50 lualib")
66
67  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
68       
69
70  IF (Lua_FOUND)
71    MESSAGE(STATUS "Lua was found.")
72    IF (VERBOSE_FIND)
73      MESSAGE (STATUS "  include path: ${Lua_INCLUDE_DIR}")
74      MESSAGE (STATUS "  library path: ${Lua_LIBRARIES}")
75      MESSAGE (STATUS "  libraries:    ${Lua_LIBRARY_NAMES}")
76    ENDIF (VERBOSE_FIND)
77  ELSE (Lua_FOUND)
78    IF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
79      MESSAGE(SEND_ERROR "Lua 5.1 library was not found")
80    ENDIF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
81    IF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
82      MESSAGE(SEND_ERROR "Lua 5.1 include path was not found")
83    ENDIF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
84
85    IF (Lua_INCLUDE_DIR_50)
86      IF (NOT Lua_LIBRARY_1_50)
87       MESSAGE(SEND_ERROR "Lua 5.0 library "lua" was not found")
88      ENDIF (NOT Lua_LIBRARY_1_50)
89      IF (NOT Lua_LIBRARY_2_50)
90       MESSAGE(SEND_ERROR "Lua 5.0 library "lualib" was not found")
91      ENDIF (NOT Lua_LIBRARY_2_50)
92    ENDIF (Lua_INCLUDE_DIR_50)
93    IF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
94      MESSAGE(SEND_ERROR "Lua 5.0 include path was not found")
95    ENDIF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
96
97    MESSAGE(SEND_ERROR "Lua was not found.")
98  ENDIF (Lua_FOUND)
99
100ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
101
Note: See TracBrowser for help on using the repository browser.