1
0

CMake: Fix system Lua usage for non-5.1 versions. (#3271)

This commit is contained in:
Mattes D 2016-07-21 11:46:31 +02:00 committed by Alexander Harkness
parent e7b4d7a776
commit fc5fb03fec
3 changed files with 32 additions and 8 deletions

View File

@ -1,3 +1,18 @@
# This is the top-level CMakeLists.txt file for the Cuberite project
#
# Use CMake to generate the build files for your platform
#
# This script supports some configuration through CMake arguments (-Dparam=val syntax):
# BUILD_TOOLS=1 sets up additional executables to be built along with the server (ProtoProxy, GrownBiomeGenVisualiser, MCADefrag)
# BUILD_UNSTABLE_TOOLS=1 sets up yet more executables to be built, these can be broken and generally are obsolete (GeneratorPerformanceTest)
# CROSSCOMPILE=1 marks the build as a crosscompile (doesn't include optimizations for current platform)
# DISABLE_SYSTEM_LUA=1 disables the use of system Lua interpreter; the tolua executable will be built and used instead. Incompatible with cross-compiling
# SELF_TEST=1 enables testing code to be built
cmake_minimum_required (VERSION 2.8.7)
if (POLICY CMP0054)
@ -96,15 +111,24 @@ endif()
set(BUILD_TOOLS OFF CACHE BOOL "")
set(SELF_TEST OFF CACHE BOOL "")
# Check whether Lua 5.1 is installed locally:
include(CheckLua.cmake)
if(HAS_LUA_INTERPRETER AND ("${LUA_INTERPRETER_VERSION}" STREQUAL "5.1"))
message(STATUS "Lua 5.1 has been found in your system and will be used for the build.")
# Check whether Lua 5.1 can be used:
if (NOT(DISABLE_SYSTEM_LUA))
include(CheckLua.cmake)
if(HAS_LUA_INTERPRETER AND ("${LUA_INTERPRETER_VERSION}" STREQUAL "5.1"))
message(STATUS "Lua 5.1 has been found in your system and will be used for the build.")
set(USE_SYSTEM_LUA 1)
else()
if (CROSSCOMPILE)
message(FATAL "To crosscompile, you need to have Lua 5.1 installed in your system and available in PATH.")
endif()
message(STATUS "Lua 5.1 has NOT been found in your system, the build will use its own Lua implementation.")
unset(USE_SYSTEM_LUA)
endif()
else()
if (CROSSCOMPILE)
message(FATAL "To crosscompile, you need to have Lua 5.1 installed in your system and available in PATH.")
message(FATAL "CMake parameter mismatch: CROSSCOMPILE is mutually exclusive with DISABLE_SYSTEM_LUA")
endif()
message(STATUS "Lua 5.1 has NOT been found in your system, the build will use its own Lua implementation.")
message(STATUS "System Lua is disabled via CMake command-line parameters. The build will use its own Lua implementation.")
endif()

View File

@ -137,7 +137,7 @@ set(BINDING_DEPENDENCIES
)
if (NOT MSVC)
if (HAS_LUA_INTERPRETER)
if (USE_SYSTEM_LUA)
ADD_CUSTOM_COMMAND(
OUTPUT ${BINDING_OUTPUTS}
COMMAND lua BindingsProcessor.lua

View File

@ -318,7 +318,7 @@ if (MSVC)
list (APPEND BINDINGS_DEPENDENCIES "Bindings/${dep}")
endforeach(dep)
if (HAS_LUA_INTERPRETER)
if (USE_SYSTEM_LUA)
ADD_CUSTOM_COMMAND(
OUTPUT ${BINDING_OUTPUTS}
COMMAND lua BindingsProcessor.lua