mirror of
https://github.com/glest/glest-source.git
synced 2025-09-01 20:12:40 +02:00
updated modules: LUA, GLEW
This commit is contained in:
@@ -1,104 +1,186 @@
|
||||
# Find the Lua 5.1 includes and library
|
||||
#.rst:
|
||||
# FindLua
|
||||
# -------
|
||||
#
|
||||
# LUA_INCLUDE_DIR - where to find lua.h
|
||||
# LUA_LIBRARIES - List of fully qualified libraries to link against
|
||||
# LUA_FOUND - Set to TRUE if found
|
||||
|
||||
# Copyright (c) 2007, Pau Garcia i Quiles, <pgquiles@elpauer.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# Locate Lua library This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# LUA_FOUND - if false, do not try to link to Lua
|
||||
# LUA_LIBRARIES - both lua and lualib
|
||||
# LUA_INCLUDE_DIR - where to find lua.h
|
||||
# LUA_VERSION_STRING - the version of Lua found
|
||||
# LUA_VERSION_MAJOR - the major version of Lua
|
||||
# LUA_VERSION_MINOR - the minor version of Lua
|
||||
# LUA_VERSION_PATCH - the patch version of Lua
|
||||
#
|
||||
#
|
||||
#
|
||||
# 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/
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
# Copyright 2013 Rolf Eike Beer <eike@sf-mail.de>
|
||||
# Copyright 2015 filux <heross(@@)o2.pl>
|
||||
#
|
||||
# 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.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
unset(_lua_include_subdirs)
|
||||
unset(_lua_library_names)
|
||||
|
||||
OPTION(WANT_STATIC_LIBS "builds as many static libs as possible" OFF)
|
||||
IF(WANT_STATIC_LIBS)
|
||||
OPTION(LUA_STATIC "Set to ON to link your project with static library (instead of DLL)." ON)
|
||||
ENDIF()
|
||||
|
||||
IF(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
|
||||
#SET(LUA_FIND_QUIETLY TRUE)
|
||||
ENDIF(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
|
||||
|
||||
IF(FORCE_LUA_5_3)
|
||||
MESSAGE(STATUS "Trying to FORCE LUA 5.3 ...")
|
||||
|
||||
SET(LUA_FIND_INCLUDE_PATHS /usr/include/lua5.3
|
||||
/usr/include/lua
|
||||
/usr/include )
|
||||
SET(LUA_FIND_STATIC_LIB_NAMES liblua5.3.a lua5.3 liblua.a lua )
|
||||
SET(LUA_FIND_DYNAMIC_LIB_NAMES lua5.3 lua )
|
||||
|
||||
ELSEIF(FORCE_LUA_5_2)
|
||||
MESSAGE(STATUS "Trying to FORCE LUA 5.2 ...")
|
||||
|
||||
SET(LUA_FIND_INCLUDE_PATHS /usr/include/lua5.2
|
||||
/usr/include/lua
|
||||
/usr/include )
|
||||
SET(LUA_FIND_STATIC_LIB_NAMES liblua5.2.a lua5.2 liblua.a lua )
|
||||
SET(LUA_FIND_DYNAMIC_LIB_NAMES lua5.2 lua )
|
||||
|
||||
ELSEIF(FORCE_LUA_5_1)
|
||||
MESSAGE(STATUS "Trying to FORCE LUA 5.1 ...")
|
||||
|
||||
SET(LUA_FIND_INCLUDE_PATHS /usr/include/lua5.1
|
||||
/usr/include/lua
|
||||
/usr/include )
|
||||
SET(LUA_FIND_STATIC_LIB_NAMES liblua5.1.a lua5.1 liblua.a lua )
|
||||
SET(LUA_FIND_DYNAMIC_LIB_NAMES lua5.1 lua )
|
||||
IF("${FORCE_LUA_VERSION}" STREQUAL "OFF")
|
||||
SET(LUA_VERSIONS5 "${ALL_LUA_VERSIONS_IN_ORDER}")
|
||||
ELSE()
|
||||
SET(LUA_FIND_INCLUDE_PATHS /usr/include/lua5.3
|
||||
/usr/include/lua5.2
|
||||
/usr/include/lua
|
||||
/usr/include/lua5.1
|
||||
/usr/include )
|
||||
SET(LUA_FIND_STATIC_LIB_NAMES liblua5.3.a liblua5.2.a liblua.a liblua5.1.a lua5.3 lua5.2 lua lua5.1 )
|
||||
SET(LUA_FIND_DYNAMIC_LIB_NAMES lua5.3 lua5.2 lua lua5.1 )
|
||||
SET(LUA_VERSIONS5 "${FORCE_LUA_VERSION}")
|
||||
ENDIF()
|
||||
|
||||
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.hpp
|
||||
PATHS ${LUA_FIND_INCLUDE_PATHS}
|
||||
IF(FreeBSD)
|
||||
SET(PATHS "/usr/local/include/lua53 /usr/local/include/lua52 /usr/local/include/lua51")
|
||||
ENDIF()
|
||||
$ENV{LUA_HOME})
|
||||
# this is a function only to have all the variables inside go away automatically
|
||||
function(set_lua_version_vars)
|
||||
if (Lua_FIND_VERSION_EXACT)
|
||||
if (Lua_FIND_VERSION_COUNT GREATER 1)
|
||||
set(lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR})
|
||||
endif ()
|
||||
elseif (Lua_FIND_VERSION)
|
||||
# once there is a different major version supported this should become a loop
|
||||
if (NOT Lua_FIND_VERSION_MAJOR GREATER 5)
|
||||
if (Lua_FIND_VERSION_COUNT EQUAL 1)
|
||||
set(lua_append_versions ${LUA_VERSIONS5})
|
||||
else ()
|
||||
foreach (subver IN LISTS LUA_VERSIONS5)
|
||||
if (NOT subver VERSION_LESS ${Lua_FIND_VERSION})
|
||||
list(APPEND lua_append_versions ${subver})
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
# once there is a different major version supported this should become a loop
|
||||
set(lua_append_versions ${LUA_VERSIONS5})
|
||||
endif ()
|
||||
|
||||
IF (LUA_STATIC AND NOT LUA_LIBRARIES)
|
||||
FIND_LIBRARY(LUA_LIBRARIES NAMES ${LUA_FIND_STATIC_LIB_NAMES}
|
||||
PATHS
|
||||
IF(FreeBSD)
|
||||
SET(PATHS "/usr/local/lib/lua53 /usr/local/lib/lua52 /usr/local/lib/lua51")
|
||||
ENDIF()
|
||||
$ENV{LUA_HOME})
|
||||
foreach (ver IN LISTS lua_append_versions)
|
||||
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
|
||||
list(APPEND _lua_include_subdirs
|
||||
include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
|
||||
include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
||||
include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
||||
)
|
||||
IF(LUA_STATIC)
|
||||
list(APPEND _lua_library_names
|
||||
liblua${CMAKE_MATCH_1}${CMAKE_MATCH_2}.a
|
||||
liblua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.a
|
||||
liblua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.a
|
||||
)
|
||||
ENDIF()
|
||||
list(APPEND _lua_library_names
|
||||
lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
|
||||
lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
||||
lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
|
||||
)
|
||||
endforeach ()
|
||||
|
||||
ELSE()
|
||||
FIND_LIBRARY(LUA_LIBRARIES NAMES ${LUA_FIND_DYNAMIC_LIB_NAMES}
|
||||
PATHS
|
||||
IF(FreeBSD)
|
||||
SET(PATHS "/usr/local/lib/lua53 /usr/local/lib/lua52 /usr/local/lib/lua51")
|
||||
ENDIF()
|
||||
$ENV{LUA_HOME})
|
||||
ENDIF()
|
||||
set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
|
||||
set(_lua_library_names "${_lua_library_names}" PARENT_SCOPE)
|
||||
endfunction(set_lua_version_vars)
|
||||
|
||||
#MESSAGE(STATUS "LUA_INC: ${LUA_INCLUDE_DIR}")
|
||||
#MESSAGE(STATUS "LUA_LIB: ${LUA_LIBRARIES}")
|
||||
set_lua_version_vars()
|
||||
|
||||
IF(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
|
||||
SET(LUA_FOUND TRUE)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
CHECK_LIBRARY_EXISTS(${LUA_LIBRARIES} lua_close "" LUA_NEED_PREFIX)
|
||||
ELSE(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
|
||||
SET(LUA_FOUND FALSE)
|
||||
ENDIF (LUA_INCLUDE_DIR AND LUA_LIBRARIES)
|
||||
find_path(LUA_INCLUDE_DIR lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES ${_lua_include_subdirs} include/lua include
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
unset(_lua_include_subdirs)
|
||||
|
||||
IF(LUA_FOUND)
|
||||
IF (NOT LUA_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Lua library: ${LUA_LIBRARIES}")
|
||||
MESSAGE(STATUS "Found Lua headers: ${LUA_INCLUDE_DIR}")
|
||||
ENDIF (NOT LUA_FIND_QUIETLY)
|
||||
ELSE(LUA_FOUND)
|
||||
IF(LUA_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could NOT find Lua")
|
||||
ENDIF(LUA_FIND_REQUIRED)
|
||||
ENDIF(LUA_FOUND)
|
||||
find_library(LUA_LIBRARY
|
||||
NAMES ${_lua_library_names} lua
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
unset(_lua_library_names)
|
||||
|
||||
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES)
|
||||
if (LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
if (UNIX AND NOT APPLE AND NOT BEOS)
|
||||
find_library(LUA_MATH_LIBRARY m)
|
||||
set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
else ()
|
||||
set(LUA_LIBRARIES "${LUA_LIBRARY}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
||||
# At least 5.[012] have different ways to express the version
|
||||
# so all of them need to be tested. Lua 5.2 defines LUA_VERSION
|
||||
# and LUA_RELEASE as joined by the C preprocessor, so avoid those.
|
||||
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_strings
|
||||
REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
|
||||
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
|
||||
if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
|
||||
set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
|
||||
else ()
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
|
||||
if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
|
||||
string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
|
||||
endif ()
|
||||
string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
|
||||
endif ()
|
||||
|
||||
unset(lua_version_strings)
|
||||
endif()
|
||||
|
||||
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(Lua
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
||||
|
||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||
|
Reference in New Issue
Block a user