Separate unix and windows in meson

This commit is contained in:
FlightlessMango 2020-09-05 07:42:39 +02:00
parent 6da5622002
commit b7aa6a997b
2 changed files with 124 additions and 101 deletions

View File

@ -30,9 +30,11 @@ else
endif
# TODO: this is very incomplete
is_unixy = false
if ['linux', 'cygwin', 'gnu'].contains(host_machine.system())
pre_args += '-D_GNU_SOURCE'
pre_args += '-DHAVE_PTHREAD'
is_unixy = true
endif
if get_option('glibcxx_asserts')
@ -77,9 +79,16 @@ endforeach
vulkan_wsi_args = []
vulkan_wsi_deps = []
if is_unixy
dep_x11 = dependency('x11', required: get_option('with_x11'))
dep_wayland_client = dependency('wayland-client',
required: get_option('with_wayland'), version : '>=1.11')
dbus_dep = dependency('dbus-1', required: get_option('with_dbus')).partial_dependency(compile_args : true, includes : true)
else
dep_x11 = null_dep
dep_wayland_client = null_dep
dbus_dep = null_dep
endif
if dep_x11.found()
vulkan_wsi_args += ['-DVK_USE_PLATFORM_XLIB_KHR']
@ -90,7 +99,7 @@ if dep_wayland_client.found()
vulkan_wsi_deps += dep_wayland_client
endif
if not dep_x11.found() and not dep_wayland_client.found()
if is_unixy and not dep_x11.found() and not dep_wayland_client.found()
error('At least one of "with_x11" and "with_wayland" should be enabled')
endif
@ -100,7 +109,6 @@ inc_common = [
dep_vulkan = dependency('vulkan', required: get_option('use_system_vulkan'))
dep_pthread = dependency('threads')
dbus_dep = dependency('dbus-1', required: get_option('with_dbus')).partial_dependency(compile_args : true, includes : true)
# Check for generic C arguments
c_args = []
@ -157,11 +165,15 @@ foreach a : cpp_args
endforeach
# check for dl support
if is_unixy
if cc.has_function('dlopen')
dep_dl = null_dep
else
dep_dl = cc.find_library('dl')
endif
else
dep_dl = null_dep
endif
# check for linking with rt by default
if cc.has_function('clock_gettime')

View File

@ -26,6 +26,15 @@ foreach s : ['overlay.frag', 'overlay.vert']
command : [glslang, '-V', '-x', '-o', '@OUTPUT@', '@INPUT@'])
endforeach
vklayer_files = []
opengl_files = []
if ['windows', 'mingw'].contains(host_machine.system())
vklayer_files += files(
)
endif
if is_unixy
vklayer_files = files(
'overlay.cpp',
'overlay_params.cpp',
@ -111,6 +120,7 @@ if dbus_dep.found() and get_option('with_dbus').enabled()
'loaders/loader_dbus.cpp',
)
endif
endif
link_args = cc.get_supported_link_arguments(['-Wl,-Bsymbolic-functions', '-Wl,-z,relro', '-Wl,--exclude-libs,ALL'])
# meson fails to check version-script so just force add
@ -147,7 +157,7 @@ vklayer_mesa_overlay = shared_library(
install_dir : libdir_mangohud,
install : true
)
if is_unixy
mangohud_dlsym = shared_library(
'MangoHud_dlsym',
files(
@ -169,6 +179,7 @@ mangohud_dlsym = shared_library(
install_dir : libdir_mangohud,
install : true
)
endif
configure_file(input : 'mangohud.json.in',
output : '@0@.json'.format(meson.project_name()),