1 | # Locate Lua library |
---|
2 | # This module defines |
---|
3 | # LUA_LIBRARIES, both lua and lualib |
---|
4 | # LUA_FOUND, if false, do not try to link to Lua |
---|
5 | # LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h) |
---|
6 | # |
---|
7 | # Note that the expected include convention is |
---|
8 | # #include "lua.h" |
---|
9 | # and not |
---|
10 | # #include <lua/lua.h> |
---|
11 | # This is because, the lua location is not standardized and may exist |
---|
12 | # in locations other than lua/ |
---|
13 | |
---|
14 | |
---|
15 | FIND_PATH(LUA_INCLUDE_DIR lua.h |
---|
16 | PATHS |
---|
17 | $ENV{LUA_DIR} |
---|
18 | NO_DEFAULT_PATH |
---|
19 | PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include |
---|
20 | ) |
---|
21 | |
---|
22 | FIND_PATH(LUA_INCLUDE_DIR lua.h |
---|
23 | PATHS |
---|
24 | ~/Library/Frameworks |
---|
25 | /Library/Frameworks |
---|
26 | /usr/local |
---|
27 | /usr |
---|
28 | /sw # Fink |
---|
29 | /opt/local # DarwinPorts |
---|
30 | /opt/csw # Blastwave |
---|
31 | /opt |
---|
32 | PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include |
---|
33 | ) |
---|
34 | |
---|
35 | FIND_LIBRARY(LUA_LIBRARY_lua |
---|
36 | NAMES lua50 lua5.0 lua5 lua |
---|
37 | PATHS |
---|
38 | $ENV{LUA_DIR} |
---|
39 | NO_DEFAULT_PATH |
---|
40 | PATH_SUFFIXES lib64 lib |
---|
41 | ) |
---|
42 | |
---|
43 | FIND_LIBRARY(LUA_LIBRARY_lua |
---|
44 | NAMES lua50 lua5.0 lua5 lua |
---|
45 | PATHS |
---|
46 | ~/Library/Frameworks |
---|
47 | /Library/Frameworks |
---|
48 | /usr/local |
---|
49 | /usr |
---|
50 | /sw |
---|
51 | /opt/local |
---|
52 | /opt/csw |
---|
53 | /opt |
---|
54 | PATH_SUFFIXES lib64 lib |
---|
55 | ) |
---|
56 | |
---|
57 | # In an OS X framework, lualib is usually included as part of the framework |
---|
58 | # (like GLU in OpenGL.framework) |
---|
59 | IF(${LUA_LIBRARY_lua} MATCHES "framework") |
---|
60 | SET( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework") |
---|
61 | ELSE(${LUA_LIBRARY_lua} MATCHES "framework") |
---|
62 | FIND_LIBRARY(LUA_LIBRARY_lualib |
---|
63 | NAMES lualib50 lualib5.0 lualib5 lualib |
---|
64 | PATHS |
---|
65 | $ENV{LUALIB_DIR} |
---|
66 | $ENV{LUA_DIR} |
---|
67 | NO_DEFAULT_PATH |
---|
68 | PATH_SUFFIXES lib64 lib |
---|
69 | ) |
---|
70 | |
---|
71 | FIND_LIBRARY(LUA_LIBRARY_lualib |
---|
72 | NAMES lualib50 lualib5.0 lualib5 lualib |
---|
73 | PATHS |
---|
74 | /usr/local |
---|
75 | /usr |
---|
76 | /sw |
---|
77 | /opt/local |
---|
78 | /opt/csw |
---|
79 | /opt |
---|
80 | PATH_SUFFIXES lib64 lib |
---|
81 | ) |
---|
82 | IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua) |
---|
83 | # include the math library for Unix |
---|
84 | IF(UNIX AND NOT APPLE) |
---|
85 | FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m) |
---|
86 | SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries") |
---|
87 | # For Windows and Mac, don't need to explicitly include the math library |
---|
88 | ELSE(UNIX AND NOT APPLE) |
---|
89 | SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries") |
---|
90 | ENDIF(UNIX AND NOT APPLE) |
---|
91 | ENDIF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua) |
---|
92 | ENDIF(${LUA_LIBRARY_lua} MATCHES "framework") |
---|
93 | |
---|
94 | |
---|
95 | INCLUDE(FindPackageHandleStandardArgs) |
---|
96 | # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if |
---|
97 | # all listed variables are TRUE |
---|
98 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) |
---|
99 | |
---|
100 | MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES) |
---|
101 | |
---|