diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2019-11-19 18:00:16 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-10-09 09:32:27 +0800 |
commit | df637cf9c020acc19394d425242bc8ee9510128d (patch) | |
tree | 67336b3505d0cc8bd391bae1d581dd5ed0c79e06 | |
parent | 37d70f4a282f990c19aee17ba838df6dd8602957 (diff) | |
download | libpeas-df637cf9c020acc19394d425242bc8ee9510128d.tar.gz |
meson.build: Improve lua search on Windows
On Windows, especially Visual Studio builds, lua does not come with a
pkg-config file, so we may need to look for the dependencies manually.
We first reverse the order of the search in such situations, by looking
for whether we have lua.exe or luajit.exe in our path, and then we look
for the lua headers and the lua library[1]. If they could be found, we
proceed to look for lua-lgi and build as we did before.
[1]: lua51.lib for luajit or lua5[3|2|1].lib for lua 5.[3|2|1].
-rw-r--r-- | meson.build | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/meson.build b/meson.build index 7efb71b..95fa986 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project( 'libpeas', 'c', version: '1.28.0', license: 'LGPLv2.1+', - meson_version: '>= 0.49.0', + meson_version: '>= 0.50.0', default_options: [ 'buildtype=debugoptimized', ] @@ -149,7 +149,51 @@ endif luajit_prg = find_program('luajit', required: false) xmllint_prg = find_program('xmllint', required: false) +if cc.get_id() == 'msvc' + if luajit_prg.found() + # luajit has lua51.lib as its import library + lua_names = ['lua51'] + else + lua_names = ['lua53', 'lua52', 'lua51'] + endif + + lua_headers = ['lua.h', 'lualib.h', 'lauxlib.h'] + # On Windows, the lua program may be named as lua.exe + foreach lua: lua_names + ['lua'] + if not lua51_prg.found() and not luajit_prg.found() + lua51_prg = find_program(lua, required: false) + endif + if lua51_prg.found() + if lua != 'lua' + lua51_dep = cc.find_library(lua, has_headers: lua_headers, required: false) + endif + endif + endforeach + + if not lua51_dep.found() and not luajit_dep.found() + foreach lualib: lua_names + if luajit_prg.found() + if not luajit_dep.found() + luajit_dep = cc.find_library(lualib, has_headers: lua_headers, required: false) + endif + endif + + if lua51_prg.found() + if not lua51_dep.found() + lua51_dep = cc.find_library(lualib, has_headers: lua_headers, required: false) + endif + endif + endforeach + endif +endif + +lua_found = false + if (luajit_dep.found() and luajit_prg.found()) or (lua51_dep.found() and lua51_prg.found()) + lua_found = true +endif + +if lua_found if luajit_prg.found() lua_prg = luajit_prg else |