Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Modules / FindLua50.cmake
blob6d952c4f1b0b5253421a9538dbf3e255f8d45894
1 # Locate Lua library
2 # This module defines
3 #  LUA50_FOUND, if false, do not try to link to Lua 
4 #  LUA_LIBRARIES, both lua and lualib
5 #  LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
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/
15 FIND_PATH(LUA_INCLUDE_DIR lua.h
16   HINTS
17   $ENV{LUA_DIR}
18   PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include
19   PATHS
20   ~/Library/Frameworks
21   /Library/Frameworks
22   /usr/local
23   /usr
24   /sw # Fink
25   /opt/local # DarwinPorts
26   /opt/csw # Blastwave
27   /opt
30 FIND_LIBRARY(LUA_LIBRARY_lua 
31   NAMES lua50 lua5.0 lua-5.0 lua5 lua
32   HINTS
33   $ENV{LUA_DIR}
34   PATH_SUFFIXES lib64 lib
35   PATHS
36   ~/Library/Frameworks
37   /Library/Frameworks
38   /usr/local
39   /usr
40   /sw
41   /opt/local
42   /opt/csw
43   /opt
46 # In an OS X framework, lualib is usually included as part of the framework
47 # (like GLU in OpenGL.framework)
48 IF(${LUA_LIBRARY_lua} MATCHES "framework")
49   SET( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework")
50 ELSE(${LUA_LIBRARY_lua} MATCHES "framework")
51   FIND_LIBRARY(LUA_LIBRARY_lualib 
52     NAMES lualib50 lualib5.0 lualib5 lualib
53     HINTS
54     $ENV{LUALIB_DIR}
55     $ENV{LUA_DIR}
56     PATH_SUFFIXES lib64 lib
57     PATHS
58     /usr/local
59     /usr
60     /sw
61     /opt/local
62     /opt/csw
63     /opt
64   )
65   IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
66     # include the math library for Unix
67     IF(UNIX AND NOT APPLE)
68       FIND_LIBRARY(MATH_LIBRARY_FOR_LUA m)
69       SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
70     # For Windows and Mac, don't need to explicitly include the math library
71     ELSE(UNIX AND NOT APPLE)
72       SET( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
73     ENDIF(UNIX AND NOT APPLE)
74   ENDIF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
75 ENDIF(${LUA_LIBRARY_lua} MATCHES "framework")
78 INCLUDE(FindPackageHandleStandardArgs)
79 # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if 
80 # all listed variables are TRUE
81 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50  DEFAULT_MSG  LUA_LIBRARIES LUA_INCLUDE_DIR)
83 MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES)