mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Lua/Cmake] Prefer LuaJIT over normal Lua (#1235)
* Add a separate FindLuaJit.cmake * Remove LuaJit from our modified FindLua51.cmake * Make use of the new FindLuaJit The reason for splitting them up like this is so we can have a preference for LuaJIT that's not determined by the search order in FindLua51.cmake as well as giving the server operators the choice to prefer normal Lua with the EQEMU_PREFER_LUA cmake option
This commit is contained in:
parent
ed71543dff
commit
10ffcf155d
@ -55,6 +55,7 @@ FIND_PACKAGE(MariaDB)
|
|||||||
FIND_PACKAGE(ZLIB)
|
FIND_PACKAGE(ZLIB)
|
||||||
FIND_PACKAGE(OpenSSL)
|
FIND_PACKAGE(OpenSSL)
|
||||||
FIND_PACKAGE(Lua51)
|
FIND_PACKAGE(Lua51)
|
||||||
|
FIND_PACKAGE(LuaJit)
|
||||||
FIND_PACKAGE(PerlLibs)
|
FIND_PACKAGE(PerlLibs)
|
||||||
FIND_PACKAGE(Sodium)
|
FIND_PACKAGE(Sodium)
|
||||||
FIND_PACKAGE(mbedTLS)
|
FIND_PACKAGE(mbedTLS)
|
||||||
@ -87,6 +88,12 @@ ELSE()
|
|||||||
MESSAGE(STATUS "* Lua: MISSING *")
|
MESSAGE(STATUS "* Lua: MISSING *")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF(LuaJit_FOUND)
|
||||||
|
MESSAGE(STATUS "* LuaJIT: FOUND *")
|
||||||
|
ELSE()
|
||||||
|
MESSAGE(STATUS "* LuaJIT: MISSING *")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(PerlLibs_FOUND)
|
IF(PerlLibs_FOUND)
|
||||||
MESSAGE(STATUS "* Perl: FOUND *")
|
MESSAGE(STATUS "* Perl: FOUND *")
|
||||||
ELSE()
|
ELSE()
|
||||||
@ -122,6 +129,7 @@ OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON)
|
|||||||
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
||||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||||
|
OPTION(EQEMU_PREFER_LUA "Build with normal Lua even if LuaJIT is found." OFF)
|
||||||
|
|
||||||
IF(EQEMU_COMMANDS_LOGGING)
|
IF(EQEMU_COMMANDS_LOGGING)
|
||||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
||||||
@ -212,7 +220,12 @@ ELSE()
|
|||||||
SET(SODIUM_LIBRARY_ENABLED OFF)
|
SET(SODIUM_LIBRARY_ENABLED OFF)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(Lua51_FOUND)
|
IF(LUAJIT_FOUND AND NOT (EQEMU_PREFER_LUA AND Lua51_FOUND))
|
||||||
|
SET(LUA_LIBRARY_TYPE " LuaJIT")
|
||||||
|
SET(LUA_LIBRARY_ENABLED ON)
|
||||||
|
SET(LUA_LIBRARY_LIBS ${LUAJIT_LIBRARY} luabind)
|
||||||
|
SET(LUA_LIBRARY_INCLUDE ${LUAJIT_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
||||||
|
ELSEIF(Lua51_FOUND )
|
||||||
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
||||||
SET(LUA_LIBRARY_ENABLED ON)
|
SET(LUA_LIBRARY_ENABLED ON)
|
||||||
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
||||||
|
|||||||
@ -38,7 +38,7 @@ locations other than lua/
|
|||||||
find_path(LUA_INCLUDE_DIR lua.h
|
find_path(LUA_INCLUDE_DIR lua.h
|
||||||
HINTS
|
HINTS
|
||||||
ENV LUA_DIR
|
ENV LUA_DIR
|
||||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include/luajit include/luajit-2.0 include
|
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
|
||||||
PATHS
|
PATHS
|
||||||
~/Library/Frameworks
|
~/Library/Frameworks
|
||||||
/Library/Frameworks
|
/Library/Frameworks
|
||||||
@ -49,7 +49,7 @@ find_path(LUA_INCLUDE_DIR lua.h
|
|||||||
)
|
)
|
||||||
|
|
||||||
find_library(LUA_LIBRARY
|
find_library(LUA_LIBRARY
|
||||||
NAMES lua51 lua5.1 lua-5.1 lua luajit51 luajit5.1 luajit-5.1 luajit
|
NAMES lua51 lua5.1 lua-5.1 lua
|
||||||
HINTS
|
HINTS
|
||||||
ENV LUA_DIR
|
ENV LUA_DIR
|
||||||
PATH_SUFFIXES lib
|
PATH_SUFFIXES lib
|
||||||
|
|||||||
91
cmake/FindLuaJit.cmake
Normal file
91
cmake/FindLuaJit.cmake
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
# Modified from the FindLua51 that comes with CMake
|
||||||
|
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
FindLuaJit
|
||||||
|
---------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Locate LuaJit library This module defines
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
LUAJIT_FOUND, if false, do not try to link to Lua
|
||||||
|
LUAJIT_LIBRARIES
|
||||||
|
LUAJIT_INCLUDE_DIR, where to find lua.h
|
||||||
|
LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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/
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
find_path(LUAJIT_INCLUDE_DIR lua.h
|
||||||
|
HINTS
|
||||||
|
ENV LUA_DIR
|
||||||
|
PATH_SUFFIXES include/luajit include/luajit-2.0 include/luajit-2.1
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LUAJIT_LIBRARY
|
||||||
|
NAMES luajit51 luajit5.1 luajit-5.1 luajit
|
||||||
|
HINTS
|
||||||
|
ENV LUA_DIR
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LUAJIT_LIBRARY)
|
||||||
|
# include the math library for Unix
|
||||||
|
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
||||||
|
find_library(LUAJIT_MATH_LIBRARY m)
|
||||||
|
set( LUAJIT_LIBRARIES "${LUAJIT_LIBRARY};${LUAJIT_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||||
|
# For Windows and Mac, don't need to explicitly include the math library
|
||||||
|
else()
|
||||||
|
set( LUAJIT_LIBRARIES "${LUAJIT_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LUAJIT_INCLUDE_DIR AND EXISTS "${LUAJIT_INCLUDE_DIR}/lua.h")
|
||||||
|
file(STRINGS "${LUAJIT_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
||||||
|
|
||||||
|
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${lua_version_str}")
|
||||||
|
unset(lua_version_str)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit
|
||||||
|
REQUIRED_VARS LUAJIT_LIBRARIES LUAJIT_INCLUDE_DIR
|
||||||
|
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||||
|
|
||||||
|
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY)
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user