2009-09-23 19:40:25 +00:00
|
|
|
#
|
2009-09-09 13:20:33 +00:00
|
|
|
# Locate Lua library
|
|
|
|
# This module defines
|
2015-01-12 22:44:42 +00:00
|
|
|
# LUA_FOUND - If false, do not try to link to Lua
|
2009-09-09 13:20:33 +00:00
|
|
|
# LUA_LIBRARIES
|
2015-01-12 22:44:42 +00:00
|
|
|
# LUA_INCLUDE_DIRS - Where to find lua.h
|
|
|
|
# LUA_DLL_DIR - (Windows) Path to the Lua DLL.
|
|
|
|
# LUA_DLL - (Windows) Name of the Lua DLL.
|
2009-09-09 13:20:33 +00:00
|
|
|
#
|
|
|
|
# Note that the expected include convention is
|
|
|
|
# #include "lua.h"
|
|
|
|
# and not
|
|
|
|
# #include <lua/lua.h>
|
|
|
|
# This is because, the lua location is not standardized and may exist
|
|
|
|
# in locations other than lua/
|
|
|
|
|
2013-09-23 21:45:55 +00:00
|
|
|
INCLUDE(FindWSWinLibs)
|
|
|
|
FindWSWinLibs("lua5*" "LUA_HINTS")
|
2009-09-09 13:20:33 +00:00
|
|
|
|
2014-09-25 10:09:23 +00:00
|
|
|
find_package(PkgConfig)
|
2015-06-06 02:04:29 +00:00
|
|
|
pkg_search_module(LUA lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50)
|
|
|
|
if(NOT LUA_FOUND)
|
|
|
|
pkg_search_module(LUA "lua<=5.2.99")
|
|
|
|
endif()
|
2014-09-25 10:09:23 +00:00
|
|
|
|
2009-09-09 13:20:33 +00:00
|
|
|
FIND_PATH(LUA_INCLUDE_DIR lua.h
|
|
|
|
HINTS
|
2014-09-25 10:09:23 +00:00
|
|
|
"${LUA_INCLUDEDIR}"
|
|
|
|
"$ENV{LUA_DIR}"
|
2013-09-23 21:45:55 +00:00
|
|
|
${LUA_HINTS}
|
2012-08-25 19:12:03 +00:00
|
|
|
PATH_SUFFIXES include/lua52 include/lua5.2 include/lua51 include/lua5.1 include/lua include
|
2009-09-09 13:20:33 +00:00
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local
|
|
|
|
/usr
|
|
|
|
/sw # Fink
|
|
|
|
/opt/local # DarwinPorts
|
|
|
|
/opt/csw # Blastwave
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
2013-05-01 10:34:15 +00:00
|
|
|
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
|
|
|
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" LUA_VERSION REGEX "LUA_VERSION_NUM")
|
|
|
|
if (LUA_VERSION)
|
|
|
|
string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_NUM[ \t]+(.+)" "\\1" LUA_VERSION "${LUA_VERSION}")
|
|
|
|
else()
|
|
|
|
set( LUA_VERSION "500")
|
|
|
|
endif()
|
|
|
|
endif()
|
2013-05-04 23:06:15 +00:00
|
|
|
string( REGEX REPLACE ".*[/\\]lua(.+)$" "\\1" LUA_INC_SUFFIX "${LUA_INCLUDE_DIR}" )
|
|
|
|
if ( LUA_INCLUDE_DIR STREQUAL LUA_INC_SUFFIX )
|
|
|
|
set( LUA_INC_SUFFIX "")
|
|
|
|
endif()
|
2013-05-01 10:34:15 +00:00
|
|
|
|
2012-06-17 12:08:42 +00:00
|
|
|
FIND_LIBRARY(LUA_LIBRARY
|
2013-05-04 23:06:15 +00:00
|
|
|
NAMES lua${LUA_INC_SUFFIX} lua52 lua5.2 lua51 lua5.1 lua
|
2009-09-09 13:20:33 +00:00
|
|
|
HINTS
|
2014-09-25 10:09:23 +00:00
|
|
|
"${LUA_LIBDIR}"
|
|
|
|
"$ENV{LUA_DIR}"
|
2013-09-23 21:45:55 +00:00
|
|
|
${LUA_HINTS}
|
2009-09-09 13:20:33 +00:00
|
|
|
PATH_SUFFIXES lib64 lib
|
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/usr/local
|
|
|
|
/usr
|
|
|
|
/sw
|
|
|
|
/opt/local
|
|
|
|
/opt/csw
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
|
|
|
INCLUDE(FindPackageHandleStandardArgs)
|
2015-01-12 22:44:42 +00:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
2009-09-09 13:20:33 +00:00
|
|
|
# all listed variables are TRUE
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LUA DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR)
|
|
|
|
|
|
|
|
IF(LUA_LIBRARY)
|
2014-12-04 00:05:29 +00:00
|
|
|
SET( LUA_LIBRARIES "${LUA_LIBRARY}")
|
2009-09-09 13:20:33 +00:00
|
|
|
SET( LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIR} )
|
2015-01-12 22:44:42 +00:00
|
|
|
if (WIN32)
|
|
|
|
set ( LUA_DLL_DIR "${LUA_HINTS}"
|
|
|
|
CACHE PATH "Path to Lua DLL"
|
|
|
|
)
|
|
|
|
file( GLOB _lua_dll RELATIVE "${LUA_DLL_DIR}"
|
|
|
|
"${LUA_DLL_DIR}/lua*.dll"
|
|
|
|
)
|
|
|
|
set ( LUA_DLL ${_lua_dll}
|
|
|
|
# We're storing filenames only. Should we use STRING instead?
|
|
|
|
CACHE FILEPATH "Lua DLL file name"
|
|
|
|
)
|
|
|
|
mark_as_advanced( LUA_DLL_DIR LUA_DLL )
|
|
|
|
endif()
|
2009-09-09 13:20:33 +00:00
|
|
|
ELSE(LUA_LIBRARY)
|
|
|
|
SET( LUA_LIBRARIES )
|
|
|
|
SET( LUA_INCLUDE_DIRS )
|
2015-01-12 22:44:42 +00:00
|
|
|
SET( LUA_DLL_DIR )
|
|
|
|
SET( LUA_DLL )
|
2009-09-09 13:20:33 +00:00
|
|
|
ENDIF(LUA_LIBRARY)
|
|
|
|
|
|
|
|
MARK_AS_ADVANCED(LUA_INCLUDE_DIRS LUA_LIBRARIES)
|