From fc5fb03fec8720341ed87848af0004b23719ac95 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 21 Jul 2016 11:46:31 +0200 Subject: CMake: Fix system Lua usage for non-5.1 versions. (#3271) --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++++------ src/Bindings/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 272f2394d..aaaac1e1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 23ba4c7e6..640fd60fa 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 13bf6e379..11e2f8376 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 -- cgit v1.2.3