2007-12-21 01:59:44 +00:00
# Locate Lua library
# This module defines
2008-03-10 17:26:11 +00:00
# LUA_LIBRARIES, both lua and lualib
# LUA_FOUND, if false, do not try to link to Lua
# LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
2007-12-21 01:59:44 +00:00
#
# Note that the expected include convention is
2008-03-10 17:26:11 +00:00
# #include "lua.h"
2007-12-21 01:59:44 +00:00
# and not
2008-03-10 17:26:11 +00:00
# #include <lua/lua.h>
2007-12-21 01:59:44 +00:00
# This is because, the lua location is not standardized and may exist
# in locations other than lua/
FIND_PATH ( LUA_INCLUDE_DIR lua.h
P A T H S
$ E N V { L U A _ D I R }
N O _ D E F A U L T _ P A T H
P A T H _ S U F F I X E S i n c l u d e / l u a 5 0 i n c l u d e / l u a 5 . 0 i n c l u d e / l u a 5 i n c l u d e / l u a i n c l u d e
)
2008-01-16 02:20:11 +00:00
2007-12-21 01:59:44 +00:00
FIND_PATH ( LUA_INCLUDE_DIR lua.h
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w # Fink
/ o p t / l o c a l # DarwinPorts
/ o p t / c s w # Blastwave
/ o p t
P A T H _ S U F F I X E S i n c l u d e / l u a 5 0 i n c l u d e / l u a 5 . 0 i n c l u d e / l u a 5 i n c l u d e / l u a i n c l u d e
)
FIND_LIBRARY ( LUA_LIBRARY_lua
N A M E S l u a 5 0 l u a 5 . 0 l u a 5 l u a
P A T H S
$ E N V { L U A _ D I R }
N O _ D E F A U L T _ P A T H
P A T H _ S U F F I X E S l i b 6 4 l i b
)
2008-01-16 02:20:11 +00:00
2007-12-21 01:59:44 +00:00
FIND_LIBRARY ( LUA_LIBRARY_lua
N A M E S l u a 5 0 l u a 5 . 0 l u a 5 l u a
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
P A T H _ S U F F I X E S l i b 6 4 l i b
)
# In an OS X framework, lualib is usually included as part of the framework
# (like GLU in OpenGL.framework)
IF ( ${ LUA_LIBRARY_lua } MATCHES "framework" )
SET ( LUA_LIBRARIES "${LUA_LIBRARY_lua}" CACHE STRING "Lua framework" )
ELSE ( ${ LUA_LIBRARY_lua } MATCHES "framework" )
FIND_LIBRARY ( LUA_LIBRARY_lualib
N A M E S l u a l i b 5 0 l u a l i b 5 . 0 l u a l i b 5 l u a l i b
P A T H S
$ E N V { L U A L I B _ D I R }
$ E N V { L U A _ D I R }
N O _ D E F A U L T _ P A T H
P A T H _ S U F F I X E S l i b 6 4 l i b
)
2008-01-16 02:20:11 +00:00
2007-12-21 01:59:44 +00:00
FIND_LIBRARY ( LUA_LIBRARY_lualib
N A M E S l u a l i b 5 0 l u a l i b 5 . 0 l u a l i b 5 l u a l i b
P A T H S
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
P A T H _ S U F F I X E S l i b 6 4 l i b
)
IF ( LUA_LIBRARY_lualib AND LUA_LIBRARY_lua )
# include the math library for Unix
IF ( UNIX AND NOT APPLE )
FIND_LIBRARY ( MATH_LIBRARY_FOR_LUA m )
SET ( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries" )
# For Windows and Mac, don't need to explicitly include the math library
ELSE ( UNIX AND NOT APPLE )
SET ( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries" )
ENDIF ( UNIX AND NOT APPLE )
ENDIF ( LUA_LIBRARY_lualib AND LUA_LIBRARY_lua )
ENDIF ( ${ LUA_LIBRARY_lua } MATCHES "framework" )
2008-03-10 17:26:11 +00:00
INCLUDE ( FindPackageHandleStandardArgs )
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS ( Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR )
2007-12-21 01:59:44 +00:00
2008-03-10 17:26:11 +00:00
MARK_AS_ADVANCED ( LUA_INCLUDE_DIR LUA_LIBRARIES )
2007-12-21 01:59:44 +00:00