summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt12
-rw-r--r--CheckLua.cmake23
-rw-r--r--src/Bindings/CMakeLists.txt27
-rw-r--r--src/CMakeLists.txt33
4 files changed, 72 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02de722bb..f5ea75ba5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,18 @@ 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.")
+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.")
+endif()
+
+
# This has to be done before any flags have been set up.
if(${BUILD_TOOLS})
message("Building tools")
diff --git a/CheckLua.cmake b/CheckLua.cmake
new file mode 100644
index 000000000..e8827fe00
--- /dev/null
+++ b/CheckLua.cmake
@@ -0,0 +1,23 @@
+# CheckLua.cmake
+
+# Checks whether the Lua standalone interpreter is installed on the host system
+# If found, sets HAS_LUA_INTERPRETER to 1 and LUA_INTERPRETER_VERSION to the version reported ("5.1" etc.)
+# If not found, unsets HAS_LUA_INTERPRETER
+
+
+
+
+execute_process(
+ COMMAND lua -e "io.stdout:write(string.match(_VERSION, '%d+%.%d+'))"
+ RESULT_VARIABLE LUA_EXECUTED
+ OUTPUT_VARIABLE LUA_INTERPRETER_VERSION
+)
+
+if ("${LUA_EXECUTED}" STREQUAL "0")
+ set(HAS_LUA_INTERPRETER 1)
+else()
+ unset(HAS_LUA_INTERPRETER)
+ unset(LUA_INTERPRETER_VERSION)
+endif()
+
+unset(LUA_EXECUTED)
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 5c79225cc..05d4c7e4f 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -56,7 +56,6 @@ set (BINDING_OUTPUTS
)
set(BINDING_DEPENDENCIES
- tolua
../Bindings/AllToLua.pkg
../Bindings/BindingsProcessor.lua
../Bindings/LuaFunctions.h
@@ -139,17 +138,21 @@ set(BINDING_DEPENDENCIES
)
if (NOT MSVC)
- ADD_CUSTOM_COMMAND(
- # add any new generated bindings here
- OUTPUT ${BINDING_OUTPUTS}
-
- # Regenerate bindings:
- COMMAND tolua -L BindingsProcessor.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-
- # add any new generation dependencies here
- DEPENDS ${BINDING_DEPENDENCIES}
- )
+ if (HAS_LUA_INTERPRETER)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${BINDING_OUTPUTS}
+ COMMAND lua BindingsProcessor.lua
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${BINDING_DEPENDENCIES}
+ )
+ else()
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${BINDING_OUTPUTS}
+ COMMAND tolua -L BindingsProcessor.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${BINDING_DEPENDENCIES} tolua
+ )
+ endif()
endif ()
set_source_files_properties(${BINDING_OUTPUTS} PROPERTIES GENERATED TRUE)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5bf55c81f..075d48968 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -252,6 +252,10 @@ else ()
foreach (hdr ${FOLDER_HDRS})
list(APPEND SOURCE "${folder}/${hdr}")
endforeach(hdr)
+
+ # Include this folder's CMakeLists.txt in the project:
+ list(APPEND SOURCE "${folder}/CMakeLists.txt")
+ source_group("${folder}" FILES "${folder}/CMakeLists.txt")
endforeach(folder)
list(APPEND SOURCE "${SRCS}")
@@ -315,19 +319,26 @@ if (MSVC)
list (APPEND BINDINGS_DEPENDENCIES "Bindings/${dep}")
endforeach(dep)
- ADD_CUSTOM_COMMAND(
- OUTPUT ${BINDING_OUTPUTS}
-
- # Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/Server/lua51.dll ./lua51.dll
+ if (HAS_LUA_INTERPRETER)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${BINDING_OUTPUTS}
+ COMMAND lua BindingsProcessor.lua
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
+ DEPENDS ${BINDINGS_DEPENDENCIES}
+ )
+ else()
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${BINDING_OUTPUTS}
- # Regenerate bindings:
- COMMAND tolua -L BindingsProcessor.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
+ # Copy the Lua DLL into the Bindings folder, so that tolua can run from there:
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/Server/lua51.dll ./lua51.dll
- # add any new generation dependencies here
- DEPENDS ${BINDINGS_DEPENDENCIES}
- )
+ # Regenerate bindings:
+ COMMAND tolua -L BindingsProcessor.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
+ DEPENDS ${BINDINGS_DEPENDENCIES} tolua
+ )
+ endif()
endif()
add_executable(${EXECUTABLE} ${SOURCE})