MangoHud/src/meson.build

248 lines
5.8 KiB
Meson
Raw Permalink Normal View History

glslang = find_program('glslangValidator')
# Needs prefix for configure_file()
if get_option('append_libdir_mangohud')
libdir_mangohud = join_paths(get_option('libdir'), 'mangohud')
ld_libdir_mangohud = get_option('prefix') + '/\$LIB/mangohud/'
else
libdir_mangohud = get_option('libdir')
ld_libdir_mangohud = get_option('prefix') + '/\$LIB/'
endif
2020-07-08 20:43:09 +00:00
# For build.sh
if get_option('ld_libdir_prefix')
# FIXME derive from libdir
ld_libdir_mangohud = get_option('prefix') + '/lib/mangohud/\$LIB/'
endif
conf_data = configuration_data()
if get_option('ld_libdir_abs')
conf_data.set('ld_libdir_mangohud_abs', ld_libdir_mangohud)
conf_data.set('ld_libdir_mangohud', '')
else
conf_data.set('ld_libdir_mangohud_abs', '')
conf_data.set('ld_libdir_mangohud', ld_libdir_mangohud)
endif
ld_libdir_mangohud_vk = ''
if get_option('prepend_libdir_vk')
ld_libdir_mangohud_vk = ld_libdir_mangohud
endif
overlay_shaders = [
'overlay.frag',
'overlay.vert',
]
overlay_spv = []
foreach s : ['overlay.frag', 'overlay.vert']
overlay_spv += custom_target(
s + '.spv.h', input : s, output : s + '.spv.h',
command : [glslang, '-V', '-x', '-o', '@OUTPUT@', '@INPUT@'])
endforeach
vklayer_files = files(
2020-11-03 14:34:18 +00:00
'hud_elements.cpp',
'overlay.cpp',
2020-09-06 11:44:19 +00:00
'overlay_params.cpp',
'font.cpp',
'keybinds.cpp',
'font_unispace.c',
'logging.cpp',
'config.cpp',
2020-09-06 11:55:02 +00:00
'gpu.cpp',
2020-09-07 04:36:35 +00:00
'vulkan.cpp',
2020-09-07 04:37:27 +00:00
'blacklist.cpp',
'file_utils.cpp',
)
2020-09-05 05:42:39 +00:00
opengl_files = []
if ['windows', 'mingw'].contains(host_machine.system())
vklayer_files += files(
2020-09-06 08:56:24 +00:00
'file_utils_win32.cpp',
2020-09-06 11:52:18 +00:00
'cpu_win32.cpp',
2020-09-07 02:38:55 +00:00
'nvapi.cpp',
2020-09-07 02:38:35 +00:00
'win/dxgi.cpp',
2020-09-05 06:09:42 +00:00
'win/main.cpp',
2020-09-05 09:16:20 +00:00
'win/kiero.cpp',
'win/d3d12_hook.cpp',
2020-09-07 05:49:14 +00:00
'win/d3d11_hook.cpp',
2020-09-06 11:55:02 +00:00
'win/d3d_shared.cpp',
2020-09-05 05:42:39 +00:00
)
endif
2020-09-05 05:42:39 +00:00
if is_unixy
vklayer_files += files(
2020-09-05 05:42:39 +00:00
'cpu.cpp',
'memory.cpp',
'iostats.cpp',
'notify.cpp',
'elfhacks.cpp',
'real_dlsym.cpp',
'pci_ids.cpp',
2021-03-16 08:50:07 +00:00
'battery.cpp',
2020-09-05 05:42:39 +00:00
)
2020-06-09 10:44:41 +00:00
2020-09-05 05:42:39 +00:00
opengl_files = files(
'gl/glad.c',
'gl/imgui_impl_opengl3.cpp',
'gl/imgui_hud.cpp',
'gl/inject_egl.cpp',
2020-06-09 10:44:41 +00:00
)
2020-09-05 05:42:39 +00:00
if get_option('with_dlsym').enabled()
pre_args += '-DHOOK_DLSYM'
endif
2020-09-05 05:42:39 +00:00
nvml_h_found = get_option('with_nvml') == 'enabled'
if get_option('with_nvml') == 'system'
nvml_h_found = cc.has_header('nvml.h')
if not nvml_h_found
error('nvml.h was not found. Disable with \'-Dwith_nvml=disabled\' if gpu stats by NVML is not needed.')
endif
pre_args += '-DUSE_SYSTEM_NVML'
endif
2020-09-05 05:42:39 +00:00
if nvml_h_found
pre_args += '-DHAVE_NVML'
vklayer_files += files(
'nvml.cpp',
'loaders/loader_nvml.cpp',
)
endif
2020-09-05 05:42:39 +00:00
if get_option('with_xnvctrl').enabled()
2020-09-05 05:42:39 +00:00
if not get_option('with_x11').enabled()
error('XNVCtrl also needs \'with_x11\'')
endif
2020-09-05 05:42:39 +00:00
xnvctrl_h_found = cc.has_header('NVCtrl/NVCtrl.h')
if not xnvctrl_h_found
error('NVCtrl.h was not found. Disable with \'-Dwith_xnvctrl=disabled\' if gpu stats by XNVCtrl is not needed.')
endif
2020-09-05 05:42:39 +00:00
pre_args += '-DHAVE_XNVCTRL'
vklayer_files += files(
'loaders/loader_nvctrl.cpp',
'nvctrl.cpp',
)
endif
2020-03-10 05:19:18 +00:00
2020-09-05 05:42:39 +00:00
if get_option('with_x11').enabled()
pre_args += '-DHAVE_X11'
vklayer_files += files(
'loaders/loader_x11.cpp',
'shared_x11.cpp',
)
opengl_files += files(
'loaders/loader_glx.cpp',
'gl/inject_glx.cpp',
)
endif
if dbus_dep.found() and get_option('with_dbus').enabled()
pre_args += '-DHAVE_DBUS'
vklayer_files += files(
'dbus.cpp',
'loaders/loader_dbus.cpp',
)
endif
# if get_option('with_libdrm_amdgpu').enabled() and dep_libdrm.found() and dep_libdrm_amdgpu.found()
if get_option('with_libdrm_amdgpu').enabled() and dep_libdrm.found()
pre_args += '-DHAVE_LIBDRM_AMDGPU'
#if dep_xcb.found() and dep_xcb_dri2.found()
vklayer_files += files(
'loaders/loader_libdrm.cpp',
)
#endif
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
link_args += '-Wl,--version-script,@0@'.format(join_paths(meson.current_source_dir(), 'mangohud.version'))
vklayer_mesa_overlay = shared_library(
'MangoHud',
2020-05-02 21:18:25 +00:00
mangohud_version,
util_files,
vk_enum_to_str,
vklayer_files,
2020-03-10 05:19:18 +00:00
opengl_files,
overlay_spv,
c_args : [
pre_args,
2020-05-10 12:11:56 +00:00
no_override_init_args,
vulkan_wsi_args
],
cpp_args : [
pre_args,
vulkan_wsi_args
],
gnu_symbol_visibility : 'hidden',
dependencies : [
2020-05-10 12:11:56 +00:00
vulkan_wsi_deps,
dearimgui_dep,
2021-07-16 00:28:46 +00:00
spdlog_dep,
dep_libdrm,
#dep_libdrm_amdgpu,
dbus_dep,
dep_dl,
dep_rt,
dep_pthread,
2020-09-06 05:50:31 +00:00
dep_vulkan,
windows_deps],
include_directories : [inc_common],
link_args : link_args,
2020-04-21 13:56:46 +00:00
install_dir : libdir_mangohud,
install : true
)
2020-09-05 05:42:39 +00:00
if is_unixy
mangohud_dlsym = shared_library(
'MangoHud_dlsym',
files(
'elfhacks.cpp',
'real_dlsym.cpp',
'hook_dlsym.cpp',
),
c_args : [
pre_args,
no_override_init_args,
],
cpp_args : [
pre_args,
],
gnu_symbol_visibility : 'hidden',
dependencies : [dep_dl],
include_directories : [inc_common],
link_args : link_args,
install_dir : libdir_mangohud,
install : true
)
endif
2020-03-14 11:22:17 +00:00
configure_file(input : 'mangohud.json.in',
output : '@0@.json'.format(meson.project_name()),
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud_vk,
2020-07-08 20:43:09 +00:00
'PROJECT_NAME' : meson.project_name().to_upper()},
2020-03-14 11:22:17 +00:00
install : true,
install_dir : join_paths(get_option('datadir'), 'vulkan', 'implicit_layer.d'),
)
2020-03-10 05:19:18 +00:00
configure_file(input : '../bin/mangohud.in',
output : 'mangohud',
configuration : conf_data,
2020-03-10 05:19:18 +00:00
install_dir : get_option('bindir'),
)
2020-03-15 15:01:08 +00:00
if get_option('include_doc')
install_data(
files('../bin/MangoHud.conf'),
install_dir : join_paths(get_option('datadir'), 'doc', 'mangohud'),
rename : ['MangoHud.conf.example']
)
endif