2007-12-21 04:59:44 +03:00
|
|
|
# Locate Lua library
|
|
|
|
# This module defines
|
2012-08-13 21:42:58 +04:00
|
|
|
# LUA51_FOUND, if false, do not try to link to Lua
|
2008-03-10 20:26:11 +03:00
|
|
|
# LUA_LIBRARIES
|
2012-01-26 02:39:21 +04:00
|
|
|
# LUA_INCLUDE_DIR, where to find lua.h
|
|
|
|
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
2007-12-21 04:59:44 +03:00
|
|
|
#
|
|
|
|
# Note that the expected include convention is
|
2008-03-10 20:26:11 +03:00
|
|
|
# #include "lua.h"
|
2007-12-21 04:59:44 +03:00
|
|
|
# and not
|
2008-03-10 20:26:11 +03:00
|
|
|
# #include <lua/lua.h>
|
2007-12-21 04:59:44 +03:00
|
|
|
# This is because, the lua location is not standardized and may exist
|
|
|
|
# in locations other than lua/
|
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2007-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
2007-12-21 04:59:44 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_path(LUA_INCLUDE_DIR lua.h
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS
|
2012-03-29 02:00:54 +04:00
|
|
|
ENV LUA_DIR
|
2012-12-04 03:42:10 +04:00
|
|
|
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
|
2007-12-21 04:59:44 +03:00
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/sw # Fink
|
|
|
|
/opt/local # DarwinPorts
|
|
|
|
/opt/csw # Blastwave
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(LUA_LIBRARY
|
2009-01-30 11:02:49 +03:00
|
|
|
NAMES lua51 lua5.1 lua-5.1 lua
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS
|
2012-03-29 02:00:54 +04:00
|
|
|
ENV LUA_DIR
|
2012-03-29 02:51:06 +04:00
|
|
|
PATH_SUFFIXES lib
|
2007-12-21 04:59:44 +03:00
|
|
|
PATHS
|
|
|
|
~/Library/Frameworks
|
|
|
|
/Library/Frameworks
|
|
|
|
/sw
|
|
|
|
/opt/local
|
|
|
|
/opt/csw
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(LUA_LIBRARY)
|
2007-12-21 04:59:44 +03: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 18:26:02 +04:00
|
|
|
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(LUA_MATH_LIBRARY m)
|
|
|
|
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
2007-12-21 04:59:44 +03:00
|
|
|
# For Windows and Mac, don't need to explicitly include the math library
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2007-12-21 04:59:44 +03:00
|
|
|
|
2012-08-13 21:47:32 +04: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-26 02:39:21 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
|
|
|
unset(lua_version_str)
|
|
|
|
endif()
|
2012-01-26 02:39:21 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-08-13 21:42:58 +04:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
2008-03-10 20:26:11 +03:00
|
|
|
# all listed variables are TRUE
|
2012-01-26 02:39:21 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
|
|
|
|
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
|
|
|
VERSION_VAR LUA_VERSION_STRING)
|
2008-03-10 20:26:11 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
2007-12-21 04:59:44 +03:00
|
|
|
|