diff --git a/meson.build b/meson.build index 7ad0328a..ac663c12 100644 --- a/meson.build +++ b/meson.build @@ -39,27 +39,39 @@ threads_dep = dependency('threads') system_lua = get_option('system-lua') if system_lua - lua_dep = dependency('lua-5.4', required: false) - if not lua_dep.found() - lua_dep = dependency('lua5.4', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua54', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua-5.3', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua5.3', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua53', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua', version: ['>=5.3.0'], required: false) - endif - if not lua_dep.found() - error ('Could not find lua. Lua version 5.4 or 5.3 required') + if get_option('system-lua-version') != 'auto' + lua_version_requested = get_option('system-lua-version') + lua_dep = dependency('lua-' + lua_version_requested, required: false) + if not lua_dep.found() + lua_dep = dependency('lua' + lua_version_requested, required: false) + endif + + if not lua_dep.found() + error('Specified Lua version "' + lua_version_requested + '" not found') + endif + else + lua_dep = dependency('lua-5.4', required: false) + if not lua_dep.found() + lua_dep = dependency('lua5.4', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua54', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua-5.3', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua5.3', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua53', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua', version: ['>=5.3.0'], required: false) + endif + if not lua_dep.found() + error ('Could not find lua. Lua version 5.4 or 5.3 required') + endif endif else lua_proj = subproject('lua', default_options: ['default_library=static']) diff --git a/meson_options.txt b/meson_options.txt index a152fbda..f93feb8f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,6 +4,9 @@ option('doc', type : 'feature', value : 'auto', description: 'Enable documentation.') option('system-lua', type : 'boolean', value : 'false', description : 'Use lua from the system instead of the bundled one') +option('system-lua-version', + type: 'string', value : 'auto', + description: 'The system lua version to use or "auto" for auto-detection') option('systemd', type: 'feature', value: 'auto', description: 'Enable installing systemd units')