diff options
author | John Szakmeister <john@szakmeister.net> | 2014-07-11 19:29:26 -0400 |
---|---|---|
committer | John Szakmeister <john@szakmeister.net> | 2014-07-11 19:29:26 -0400 |
commit | 77db0b2bba97603e59614bb95d6eab76e42f9288 (patch) | |
tree | 63401fd0e0b5ca766695366a32e05ab956ae1475 | |
parent | e47968537cfc958b991ff10c6be1dcda65cb95f0 (diff) | |
parent | 5d44f89a8cdd41531177f041fb73f106c03686d8 (diff) | |
download | rneovim-77db0b2bba97603e59614bb95d6eab76e42f9288.tar.gz rneovim-77db0b2bba97603e59614bb95d6eab76e42f9288.tar.bz2 rneovim-77db0b2bba97603e59614bb95d6eab76e42f9288.zip |
Merge #932 'Check lua dependencies for all lua interpreters'
-rw-r--r-- | CMakeLists.txt | 46 | ||||
-rw-r--r-- | cmake/LuaHelpers.cmake | 38 |
2 files changed, 59 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b58f717eb6..b95f7fd277 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,36 +91,32 @@ find_package(Threads REQUIRED) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -find_program(LUA_PRG luajit) - -# Need a lua interpreter for running the msgapck metadata/dispatch generator -if(NOT EXISTS ${LUA_PRG}) - find_program(LUA_PRG lua) -endif() - -if(EXISTS ${LUA_PRG}) - message(STATUS "Using the lua interpreter ${LUA_PRG}") +# Find Lua interpreter +include(LuaHelpers) +set(LUA_DEPENDENCIES lpeg cmsgpack) +if(NOT LUA_PRG) + foreach(CURRENT_LUA_PRG luajit lua) + # If LUA_PRG is set find_program() will not search + unset(LUA_PRG CACHE) + unset(LUA_PRG_WORKS) + find_program(LUA_PRG ${CURRENT_LUA_PRG}) + + if(LUA_PRG) + check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS) + if(LUA_PRG_WORKS) + break() + endif() + endif() + endforeach() else() - message(FATAL_ERROR "A lua interpreter is required for building the Neovim") + check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS) endif() -execute_process(COMMAND ${LUA_PRG} -e "require('lpeg')" - RESULT_VARIABLE LUA_LPEG_MISSING - ERROR_QUIET) - -if(${LUA_LPEG_MISSING}) - message(FATAL_ERROR - "The 'lpeg' lua package is required for building Neovim") +if(NOT LUA_PRG_WORKS) + message(FATAL_ERROR "A suitable Lua interpreter was not found") endif() -execute_process(COMMAND ${LUA_PRG} -e "require('cmsgpack')" - RESULT_VARIABLE LUA_MSGPACK_MISSING - ERROR_QUIET) - -if(${LUA_MSGPACK_MISSING}) - message(FATAL_ERROR - "The 'cmsgpack' lua package is required for building Neovim") -endif() +message(STATUS "Using the Lua interpreter ${LUA_PRG}") add_subdirectory(config) add_subdirectory(src/nvim) diff --git a/cmake/LuaHelpers.cmake b/cmake/LuaHelpers.cmake new file mode 100644 index 0000000000..b1e67e0ca7 --- /dev/null +++ b/cmake/LuaHelpers.cmake @@ -0,0 +1,38 @@ +# +# Functions to help checking for a Lua interpreter +# + +# Check if a module is available in Lua +function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR) + execute_process(COMMAND ${LUA_PRG_PATH} -e "require('${MODULE}')" + RESULT_VARIABLE module_missing + ERROR_QUIET) + if(module_missing) + message(STATUS + "[${LUA_PRG_PATH}] The '${MODULE}' lua package is required for building Neovim") + set(${RESULT_VAR} False PARENT_SCOPE) + else() + set(${RESULT_VAR} True PARENT_SCOPE) + endif() +endfunction() + +# Check Lua interpreter for dependencies +function(check_lua_deps LUA_PRG_PATH MODULES RESULT_VAR) + # Check if the lua interpreter at the given path + # satisfies all Neovim dependencies + message(STATUS "Checking Lua interpreter ${LUA_PRG_PATH}") + if(NOT EXISTS ${LUA_PRG_PATH}) + message(STATUS + "[${LUA_PRG_PATH}] file not found") + endif() + + foreach(module ${MODULES}) + check_lua_module(${LUA_PRG_PATH} ${module} has_module) + if(NOT has_module) + set(${RESULT_VAR} False PARENT_SCOPE) + return() + endif() + endforeach() + + set(${RESULT_VAR} True PARENT_SCOPE) +endfunction() |