parent
0e24a0beae
commit
430b623223
@ -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")
|
||||
|
23
CheckLua.cmake
Normal file
23
CheckLua.cmake
Normal file
@ -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)
|
@ -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)
|
||||
if (HAS_LUA_INTERPRETER)
|
||||
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
|
||||
COMMAND lua BindingsProcessor.lua
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
|
||||
# add any new generation dependencies here
|
||||
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)
|
||||
|
@ -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,6 +319,14 @@ if (MSVC)
|
||||
list (APPEND BINDINGS_DEPENDENCIES "Bindings/${dep}")
|
||||
endforeach(dep)
|
||||
|
||||
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}
|
||||
|
||||
@ -324,10 +336,9 @@ if (MSVC)
|
||||
# Regenerate bindings:
|
||||
COMMAND tolua -L BindingsProcessor.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
|
||||
|
||||
# add any new generation dependencies here
|
||||
DEPENDS ${BINDINGS_DEPENDENCIES}
|
||||
DEPENDS ${BINDINGS_DEPENDENCIES} tolua
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(${EXECUTABLE} ${SOURCE})
|
||||
|
Loading…
Reference in New Issue
Block a user