2016-09-27 19:01:08 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 15:17:36 +00:00
|
|
|
#.rst:
|
|
|
|
# FindLua51
|
|
|
|
# ---------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Locate Lua library This module defines
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# LUA51_FOUND, if false, do not try to link to Lua
|
|
|
|
# LUA_LIBRARIES
|
|
|
|
# LUA_INCLUDE_DIR, where to find lua.h
|
|
|
|
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
|
|
|
#
|
|
|
|
#
|
2007-12-21 01:59:44 +00:00
|
|
|
#
|
|
|
|
# Note that the expected include convention is
|
2013-10-15 15:17:36 +00:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# #include "lua.h"
|
|
|
|
#
|
2007-12-21 01:59:44 +00:00
|
|
|
# and not
|
2013-10-15 15:17:36 +00:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# #include <lua/lua.h>
|
|
|
|
#
|
|
|
|
# This is because, the lua location is not standardized and may exist in
|
|
|
|
# locations other than lua/
|
2007-12-21 01:59:44 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_path(LUA_INCLUDE_DIR lua.h
|
2008-06-09 20:04:06 +00:00
|
|
|
HINTS
|
2012-03-28 22:00:54 +00:00
|
|
|
ENV LUA_DIR
|
2012-12-03 23:42:10 +00:00
|
|
|
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
|
2007-12-21 01:59:44 +00:00
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/sw # Fink
|
|
|
|
/opt/local # DarwinPorts
|
|
|
|
/opt/csw # Blastwave
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_library(LUA_LIBRARY
|
2009-01-30 08:02:49 +00:00
|
|
|
NAMES lua51 lua5.1 lua-5.1 lua
|
2008-06-09 20:04:06 +00:00
|
|
|
HINTS
|
2012-03-28 22:00:54 +00:00
|
|
|
ENV LUA_DIR
|
2012-03-28 22:51:06 +00:00
|
|
|
PATH_SUFFIXES lib
|
2007-12-21 01:59:44 +00:00
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/sw
|
|
|
|
/opt/local
|
|
|
|
/opt/csw
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(LUA_LIBRARY)
|
2007-12-21 01:59:44 +00:00
|
|
|
# include the math library for Unix
|
Haiku: Several fixes to platform module
* Do not define BEOS anymore (this includes workarounds which we don't
need most of the time in Haiku, so we prefer opt-in IF(HAIKU) in the
cmake files instead).
* On the other hand, do define UNIX (we are trying to be compliant) and
HAIKU (there is still a number of things we don't do like the
average UNIX clone)
* Do not use UnixPaths, as our filesystem hierarchy isn't anything like
what it expects.
* Do not use -nostart, which the compiler doesn't know about anymore.
This used to be an Haiku extension to gcc, and is equivalent to
-shared which is the default gcc option.
* While "dl" functions are provided in libroot, this is always
implicitly linked so there is no need to tell cmake about it.
* Forcing position-independent code is not needed, so remove it.
* On the other hand, include appropriate linker options for executables
and shared libraries.
* Support for the two available compilers in Haiku (gcc2 and gcc4) and
pick the right headers and libraries according to the currently
selected one.
* With the adoption of the package manager, the directory layout was
changed. Tell cmake where to look for header files and libraries.
* As we don't define BEOS anymore, enable the workaround we still need
for HAIKU as well. This is the lack of a libm (it is part of the
implicitly linked in libroot)
Applied-by: Rolf Eike Beer <eike@sf-mail.de>
2013-10-05 14:26:02 +00:00
|
|
|
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
2012-08-13 17:47:32 +00:00
|
|
|
find_library(LUA_MATH_LIBRARY m)
|
|
|
|
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
2007-12-21 01:59:44 +00:00
|
|
|
# For Windows and Mac, don't need to explicitly include the math library
|
2012-08-13 17:50:14 +00:00
|
|
|
else()
|
2012-08-13 17:47:32 +00:00
|
|
|
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2007-12-21 01:59:44 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
|
|
|
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
2012-01-25 22:39:21 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
|
|
|
unset(lua_version_str)
|
|
|
|
endif()
|
2012-01-25 22:39:21 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-08-13 17:42:58 +00:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
2008-03-10 17:26:11 +00:00
|
|
|
# all listed variables are TRUE
|
2012-01-25 22:39:21 +00:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
|
|
|
|
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
|
|
|
VERSION_VAR LUA_VERSION_STRING)
|
2008-03-10 17:26:11 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
2007-12-21 01:59:44 +00:00
|
|
|
|