2020-03-12 07:24:37 +00:00
|
|
|
project('MangoHud',
|
2020-01-28 04:11:05 +00:00
|
|
|
['c', 'cpp'],
|
2021-10-18 16:33:26 +00:00
|
|
|
version : 'v0.6.6',
|
2020-01-28 04:11:05 +00:00
|
|
|
license : 'MIT',
|
2021-08-08 19:00:05 +00:00
|
|
|
meson_version: '>=0.54.0',
|
2020-01-29 10:23:51 +00:00
|
|
|
default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++14']
|
2020-01-28 04:11:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
cpp = meson.get_compiler('cpp')
|
2020-12-27 20:55:26 +00:00
|
|
|
prog_python = import('python').find_installation('python3', modules: ['mako'])
|
2020-01-30 17:52:15 +00:00
|
|
|
null_dep = dependency('', required : false)
|
2020-01-28 04:11:05 +00:00
|
|
|
|
2020-05-02 16:39:39 +00:00
|
|
|
mangohud_version = vcs_tag(
|
|
|
|
command: ['git', 'describe', '--tags', '--dirty=+'],
|
|
|
|
input: 'version.h.in',
|
|
|
|
output: 'version.h')
|
|
|
|
|
2020-01-28 04:11:05 +00:00
|
|
|
pre_args = [
|
|
|
|
'-D__STDC_CONSTANT_MACROS',
|
|
|
|
'-D__STDC_FORMAT_MACROS',
|
|
|
|
'-D__STDC_LIMIT_MACROS',
|
|
|
|
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
|
2021-08-10 23:13:31 +00:00
|
|
|
'-DSPDLOG_COMPILED_LIB'
|
2020-01-28 04:11:05 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# Define DEBUG for debug builds only (debugoptimized is not included on this one)
|
|
|
|
if get_option('buildtype') == 'debug'
|
|
|
|
pre_args += '-DDEBUG'
|
2021-07-21 16:48:45 +00:00
|
|
|
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE'
|
2020-01-29 10:23:51 +00:00
|
|
|
else
|
|
|
|
pre_args += '-DNDEBUG'
|
2021-07-21 16:48:45 +00:00
|
|
|
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_' + get_option('loglevel').to_upper()
|
2020-01-28 04:11:05 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# TODO: this is very incomplete
|
2020-09-05 05:42:39 +00:00
|
|
|
is_unixy = false
|
2020-01-28 04:11:05 +00:00
|
|
|
if ['linux', 'cygwin', 'gnu'].contains(host_machine.system())
|
|
|
|
pre_args += '-D_GNU_SOURCE'
|
|
|
|
pre_args += '-DHAVE_PTHREAD'
|
2020-09-05 05:42:39 +00:00
|
|
|
is_unixy = true
|
2020-01-28 04:11:05 +00:00
|
|
|
endif
|
|
|
|
|
2020-02-04 08:10:26 +00:00
|
|
|
if get_option('glibcxx_asserts')
|
|
|
|
pre_args += '-D_GLIBCXX_ASSERTIONS'
|
|
|
|
endif
|
|
|
|
|
2020-01-28 04:11:05 +00:00
|
|
|
# Check for GCC style atomics
|
|
|
|
if cc.compiles('''#include <stdint.h>
|
|
|
|
int main() {
|
|
|
|
struct {
|
|
|
|
uint64_t *v;
|
|
|
|
} x;
|
|
|
|
return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
|
|
|
|
(int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
|
|
|
|
|
|
|
|
}''',
|
|
|
|
name : 'GCC atomic builtins')
|
|
|
|
pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Not in C99, needs POSIX
|
|
|
|
if cc.compiles('''
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <time.h>
|
|
|
|
int main() {
|
|
|
|
struct timespec ts;
|
|
|
|
return timespec_get(&ts, TIME_UTC);
|
|
|
|
|
|
|
|
}''',
|
|
|
|
name : 'Supports timespec_get')
|
|
|
|
pre_args += '-DHAVE_TIMESPEC_GET'
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Check for GCC style builtins
|
|
|
|
foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
|
|
|
|
'ffsll', 'popcount', 'popcountll', 'unreachable']
|
|
|
|
if cc.has_function(b)
|
|
|
|
pre_args += '-DHAVE___BUILTIN_@0@'.format(b.to_upper())
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
vulkan_wsi_args = []
|
|
|
|
vulkan_wsi_deps = []
|
|
|
|
|
2020-09-05 05:42:39 +00:00
|
|
|
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)
|
2020-10-22 18:37:20 +00:00
|
|
|
dep_libdrm = dependency('libdrm', required: get_option('with_libdrm_amdgpu')).partial_dependency(compile_args : true, includes : true)
|
|
|
|
# dep_libdrm_amdgpu = dependency('libdrm_amdgpu', version : '>=2.4.79', required: get_option('with_libdrm_amdgpu')).partial_dependency(compile_args : true, includes : true)
|
2020-09-05 05:42:39 +00:00
|
|
|
else
|
|
|
|
dep_x11 = null_dep
|
|
|
|
dep_wayland_client = null_dep
|
|
|
|
dbus_dep = null_dep
|
2020-10-22 18:37:20 +00:00
|
|
|
dep_libdrm = null_dep
|
|
|
|
# dep_libdrm_amdgpu = null_dep
|
2020-09-05 05:42:39 +00:00
|
|
|
endif
|
2020-01-28 04:11:05 +00:00
|
|
|
|
2020-02-11 21:29:29 +00:00
|
|
|
if dep_x11.found()
|
2020-01-29 07:55:18 +00:00
|
|
|
vulkan_wsi_args += ['-DVK_USE_PLATFORM_XLIB_KHR']
|
2020-04-01 19:52:12 +00:00
|
|
|
vulkan_wsi_deps += dep_x11.partial_dependency(compile_args : true, includes : true)
|
2020-01-28 04:11:05 +00:00
|
|
|
endif
|
2020-02-11 21:29:29 +00:00
|
|
|
if dep_wayland_client.found()
|
2020-01-28 04:11:05 +00:00
|
|
|
vulkan_wsi_args += ['-DVK_USE_PLATFORM_WAYLAND_KHR']
|
|
|
|
vulkan_wsi_deps += dep_wayland_client
|
|
|
|
endif
|
|
|
|
|
2020-09-05 05:42:39 +00:00
|
|
|
if is_unixy and not dep_x11.found() and not dep_wayland_client.found()
|
2020-02-11 21:29:29 +00:00
|
|
|
error('At least one of "with_x11" and "with_wayland" should be enabled')
|
|
|
|
endif
|
|
|
|
|
2020-01-28 04:11:05 +00:00
|
|
|
inc_common = [
|
|
|
|
include_directories('include'),
|
|
|
|
]
|
|
|
|
|
2020-02-13 18:16:31 +00:00
|
|
|
dep_vulkan = dependency('vulkan', required: get_option('use_system_vulkan'))
|
2020-03-22 00:44:17 +00:00
|
|
|
dep_pthread = dependency('threads')
|
2020-02-13 18:16:31 +00:00
|
|
|
|
2020-01-28 04:11:05 +00:00
|
|
|
# Check for generic C arguments
|
|
|
|
c_args = []
|
|
|
|
foreach a : ['-Werror=implicit-function-declaration',
|
|
|
|
'-Werror=missing-prototypes', '-Werror=return-type',
|
|
|
|
'-Werror=incompatible-pointer-types',
|
2022-03-06 13:28:49 +00:00
|
|
|
'-Wno-unused-parameter', '-Qunused-arguments',
|
|
|
|
'-fno-math-errno', '-fno-trapping-math']
|
2020-01-28 04:11:05 +00:00
|
|
|
if cc.has_argument(a)
|
|
|
|
c_args += a
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
foreach a : ['missing-field-initializers', 'format-truncation']
|
|
|
|
if cc.has_argument('-W' + a)
|
|
|
|
c_args += '-Wno-' + a
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
# Check for generic C++ arguments
|
|
|
|
cpp_args = []
|
|
|
|
foreach a : ['-Werror=return-type',
|
2022-03-06 13:28:49 +00:00
|
|
|
'-Wno-unused-parameter', '-Qunused-arguments',
|
|
|
|
'-fno-math-errno', '-fno-trapping-math']
|
2020-01-28 04:11:05 +00:00
|
|
|
if cpp.has_argument(a)
|
|
|
|
cpp_args += a
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
# For some reason, the test for -Wno-foo always succeeds with gcc, even if the
|
|
|
|
# option is not supported. Hence, check for -Wfoo instead.
|
|
|
|
|
2020-01-29 18:36:25 +00:00
|
|
|
foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation']
|
2020-01-28 04:11:05 +00:00
|
|
|
if cpp.has_argument('-W' + a)
|
|
|
|
cpp_args += '-Wno-' + a
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
no_override_init_args = []
|
|
|
|
foreach a : ['override-init', 'initializer-overrides']
|
|
|
|
if cc.has_argument('-W' + a)
|
|
|
|
no_override_init_args += '-Wno-' + a
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
foreach a : pre_args
|
|
|
|
add_project_arguments(a, language : ['c', 'cpp'])
|
|
|
|
endforeach
|
|
|
|
foreach a : c_args
|
|
|
|
add_project_arguments(a, language : ['c'])
|
|
|
|
endforeach
|
|
|
|
foreach a : cpp_args
|
|
|
|
add_project_arguments(a, language : ['cpp'])
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
# check for dl support
|
2020-09-05 05:42:39 +00:00
|
|
|
if is_unixy
|
|
|
|
if cc.has_function('dlopen')
|
|
|
|
dep_dl = null_dep
|
|
|
|
else
|
|
|
|
dep_dl = cc.find_library('dl')
|
|
|
|
endif
|
2020-09-05 09:16:20 +00:00
|
|
|
# check for linking with rt by default
|
|
|
|
if cc.has_function('clock_gettime')
|
|
|
|
dep_rt = null_dep
|
|
|
|
else
|
|
|
|
dep_rt = cc.find_library('rt')
|
|
|
|
endif
|
2020-01-28 04:11:05 +00:00
|
|
|
else
|
2020-09-05 05:42:39 +00:00
|
|
|
dep_dl = null_dep
|
2020-04-26 19:43:40 +00:00
|
|
|
dep_rt = null_dep
|
|
|
|
endif
|
|
|
|
|
2020-02-13 18:16:31 +00:00
|
|
|
if dep_vulkan.found()
|
2021-05-11 15:44:25 +00:00
|
|
|
datadir = get_option('vulkan_datadir')
|
|
|
|
if datadir == ''
|
|
|
|
datadir = get_option('datadir')
|
|
|
|
endif
|
2020-02-13 18:16:31 +00:00
|
|
|
if not datadir.startswith('/')
|
|
|
|
datadir = get_option('prefix') / datadir
|
|
|
|
endif
|
|
|
|
vk_api_xml = files(datadir / 'vulkan/registry/vk.xml')
|
|
|
|
else
|
2020-06-02 09:50:19 +00:00
|
|
|
vkh_sp = subproject('vulkan-headers')
|
2020-03-17 10:18:10 +00:00
|
|
|
vk_api_xml = vkh_sp.get_variable('vulkan_api_xml')
|
2020-06-02 09:50:19 +00:00
|
|
|
dep_vulkan = vkh_sp.get_variable('vulkan_headers_dep')
|
2020-02-13 18:16:31 +00:00
|
|
|
endif
|
|
|
|
|
2020-01-28 04:11:05 +00:00
|
|
|
vk_enum_to_str = custom_target(
|
|
|
|
'vk_enum_to_str',
|
|
|
|
input : ['bin/gen_enum_to_str.py', vk_api_xml],
|
|
|
|
output : ['vk_enum_to_str.c', 'vk_enum_to_str.h'],
|
|
|
|
command : [
|
|
|
|
prog_python, '@INPUT0@', '--xml', '@INPUT1@',
|
|
|
|
'--outdir', meson.current_build_dir()
|
|
|
|
],
|
|
|
|
)
|
2020-03-11 16:04:10 +00:00
|
|
|
|
2020-01-28 04:11:05 +00:00
|
|
|
util_files = files(
|
|
|
|
'src/mesa/util/os_socket.c',
|
|
|
|
'src/mesa/util/os_time.c',
|
|
|
|
)
|
2020-03-23 19:19:03 +00:00
|
|
|
|
2021-10-18 17:19:59 +00:00
|
|
|
imgui_options = [
|
|
|
|
'default_library=static',
|
|
|
|
# use 'auto_features=disabled' once available: https://github.com/mesonbuild/meson/issues/5320
|
|
|
|
'dx9=disabled',
|
|
|
|
'dx10=disabled',
|
|
|
|
'dx11=disabled',
|
|
|
|
'dx12=disabled',
|
|
|
|
'metal=disabled',
|
|
|
|
'opengl=disabled',
|
|
|
|
'vulkan=disabled',
|
|
|
|
'glfw=disabled',
|
|
|
|
'sdl2=disabled',
|
|
|
|
'osx=disabled',
|
|
|
|
'win=disabled',
|
|
|
|
'marmalade=disabled',
|
|
|
|
'allegro5=disabled',
|
|
|
|
]
|
|
|
|
|
2020-04-15 16:45:59 +00:00
|
|
|
sizeof_ptr = cc.sizeof('void*')
|
|
|
|
if sizeof_ptr == 8
|
2020-03-23 19:12:02 +00:00
|
|
|
pre_args += '-DMANGOHUD_ARCH="64bit"'
|
2021-10-18 16:58:39 +00:00
|
|
|
if get_option('mangoapp')
|
2021-10-18 17:19:59 +00:00
|
|
|
imgui_options += [
|
2021-10-18 16:58:39 +00:00
|
|
|
'opengl=enabled',
|
|
|
|
'glfw=enabled',
|
|
|
|
]
|
|
|
|
endif
|
2021-10-18 15:50:27 +00:00
|
|
|
elif sizeof_ptr == 4
|
|
|
|
pre_args += '-DMANGOHUD_ARCH="32bit"'
|
|
|
|
endif
|
|
|
|
|
2021-10-18 16:58:39 +00:00
|
|
|
dearimgui_sp = subproject('imgui', default_options: imgui_options)
|
2020-12-25 17:06:07 +00:00
|
|
|
dearimgui_dep = dearimgui_sp.get_variable('imgui_dep')
|
2020-05-04 10:16:09 +00:00
|
|
|
|
2021-07-16 00:28:46 +00:00
|
|
|
spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
|
|
|
|
if not spdlog_dep.found()
|
|
|
|
spdlog_sp = subproject('spdlog', default_options: [
|
|
|
|
'default_library=static',
|
2021-08-10 23:13:31 +00:00
|
|
|
'compile_library=true',
|
2021-07-16 00:28:46 +00:00
|
|
|
])
|
|
|
|
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
|
|
|
|
else
|
|
|
|
spdlog_dep = dependency('spdlog', required: true)
|
|
|
|
endif
|
|
|
|
|
2020-09-05 05:42:15 +00:00
|
|
|
if ['windows', 'mingw'].contains(host_machine.system())
|
|
|
|
subdir('modules/minhook')
|
2020-09-06 05:50:31 +00:00
|
|
|
inc_common += ( include_directories('modules/minhook/include'))
|
2020-09-05 05:42:15 +00:00
|
|
|
windows_deps = [
|
2020-09-05 09:16:20 +00:00
|
|
|
minhook_dep,
|
2020-09-05 05:42:15 +00:00
|
|
|
]
|
|
|
|
else
|
|
|
|
windows_deps = null_dep
|
|
|
|
endif
|
|
|
|
|
2021-10-18 17:14:58 +00:00
|
|
|
if get_option('mangoapp')
|
|
|
|
glfw3_dep = dependency('glfw3')
|
|
|
|
endif
|
2021-09-06 06:21:10 +00:00
|
|
|
|
2020-01-29 10:23:51 +00:00
|
|
|
subdir('src')
|
2020-07-25 09:33:23 +00:00
|
|
|
subdir('data')
|