LuaHelpers.cmake 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #
  2. # Functions to help checking for a Lua interpreter
  3. #
  4. # Check if a module is available in Lua
  5. function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR)
  6. execute_process(COMMAND ${LUA_PRG_PATH} -l "${MODULE}" -e ""
  7. RESULT_VARIABLE module_missing)
  8. if(module_missing)
  9. set(${RESULT_VAR} False PARENT_SCOPE)
  10. else()
  11. set(${RESULT_VAR} True PARENT_SCOPE)
  12. endif()
  13. endfunction()
  14. # Check Lua interpreter for dependencies
  15. function(check_lua_deps LUA_PRG_PATH MODULES RESULT_VAR)
  16. # Check if the lua interpreter at the given path
  17. # satisfies all Neovim dependencies
  18. message(STATUS "Checking Lua interpreter: ${LUA_PRG_PATH}")
  19. if(NOT EXISTS ${LUA_PRG_PATH})
  20. message(STATUS
  21. "[${LUA_PRG_PATH}] file not found")
  22. endif()
  23. foreach(module ${MODULES})
  24. check_lua_module(${LUA_PRG_PATH} ${module} has_module)
  25. if(NOT has_module)
  26. message(STATUS
  27. "[${LUA_PRG_PATH}] The '${module}' lua package is required for building Neovim")
  28. set(${RESULT_VAR} False PARENT_SCOPE)
  29. return()
  30. endif()
  31. endforeach()
  32. set(${RESULT_VAR} True PARENT_SCOPE)
  33. endfunction()