2020-03-12 07:24:37 +00:00
|
|
|
project('MangoHud',
|
2020-01-28 04:11:05 +00:00
|
|
|
['c', 'cpp'],
|
2024-05-26 22:36:40 +00:00
|
|
|
version : 'v0.7.2',
|
2020-01-28 04:11:05 +00:00
|
|
|
license : 'MIT',
|
2022-07-14 13:59:20 +00:00
|
|
|
meson_version: '>=0.60.0',
|
2022-03-06 13:29:47 +00:00
|
|
|
default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++14', 'warning_level=2']
|
2020-01-28 04:11:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
cpp = meson.get_compiler('cpp')
|
2022-11-15 23:31:20 +00:00
|
|
|
|
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')
|
|
|
|
|
2023-03-10 20:34:26 +00:00
|
|
|
mangohud_version_dep = declare_dependency(sources : mangohud_version)
|
|
|
|
|
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
|
|
|
]
|
|
|
|
|
2023-10-07 21:18:17 +00:00
|
|
|
# Always set max spdlog level, handle this using MANGOHUD_LOG_LEVEL instead.
|
2023-10-07 22:33:27 +00:00
|
|
|
if get_option('buildtype') == 'debug'
|
|
|
|
pre_args += '-DDEBUG'
|
2023-10-10 09:08:07 +00:00
|
|
|
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE'
|
2023-10-12 03:34:21 +00:00
|
|
|
else
|
|
|
|
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG'
|
2023-10-07 22:33:27 +00:00
|
|
|
endif
|
2020-01-28 04:11:05 +00:00
|
|
|
# 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)
|
2024-02-19 12:59:51 +00:00
|
|
|
dep_xkb = dependency('xkbcommon', required: get_option('with_wayland'))
|
2020-09-05 05:42:39 +00:00
|
|
|
else
|
|
|
|
dep_x11 = null_dep
|
|
|
|
dep_wayland_client = null_dep
|
|
|
|
dbus_dep = null_dep
|
|
|
|
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
|
2024-02-19 12:59:51 +00:00
|
|
|
vulkan_wsi_deps += dep_xkb
|
2020-01-28 04:11:05 +00:00
|
|
|
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-03-22 00:44:17 +00:00
|
|
|
dep_pthread = dependency('threads')
|
2020-02-13 18:16:31 +00:00
|
|
|
|
2023-03-03 10:13:31 +00:00
|
|
|
add_project_arguments(
|
|
|
|
cc.get_supported_arguments([
|
|
|
|
'-Werror=implicit-function-declaration',
|
2023-03-03 10:43:59 +00:00
|
|
|
'-Werror=missing-declarations',
|
2023-03-03 10:13:31 +00:00
|
|
|
'-Werror=missing-prototypes',
|
|
|
|
'-Werror=return-type',
|
|
|
|
'-Werror=incompatible-pointer-types',
|
|
|
|
'-Wno-unused-parameter',
|
|
|
|
'-Qunused-arguments',
|
|
|
|
'-fno-math-errno',
|
|
|
|
'-fno-trapping-math',
|
|
|
|
'-Wno-missing-field-initializers',
|
|
|
|
]), language : ['c'],
|
|
|
|
)
|
2020-01-28 04:11:05 +00:00
|
|
|
|
2023-03-03 10:13:31 +00:00
|
|
|
add_project_arguments(
|
|
|
|
cpp.get_supported_arguments([
|
2023-03-03 10:43:59 +00:00
|
|
|
'-Werror=missing-declarations',
|
2023-03-03 10:13:31 +00:00
|
|
|
'-Werror=return-type',
|
|
|
|
'-Wno-unused-parameter',
|
|
|
|
'-Qunused-arguments',
|
|
|
|
'-fno-math-errno',
|
|
|
|
'-fno-trapping-math',
|
|
|
|
'-Wno-non-virtual-dtor',
|
|
|
|
'-Wno-missing-field-initializers',
|
|
|
|
]), language : ['cpp'],
|
|
|
|
)
|
2020-01-28 04:11:05 +00:00
|
|
|
|
|
|
|
foreach a : pre_args
|
|
|
|
add_project_arguments(a, language : ['c', '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
|
|
|
|
|
2024-05-09 20:52:21 +00:00
|
|
|
# Commented code can be used if mangohud start using latest SDK Vulkan-Headers
|
|
|
|
# Allowing user to build mangohud using system Vulkan-Headers
|
|
|
|
#if not dependency('VulkanHeaders').found()
|
|
|
|
vkh_sp = subproject('vulkan-headers')
|
|
|
|
vk_api_xml = vkh_sp.get_variable('vulkan_api_xml')
|
|
|
|
dep_vulkan = vkh_sp.get_variable('vulkan_headers_dep')
|
|
|
|
#else
|
|
|
|
# dep_vulkan = dependency('VulkanHeaders', required: true)
|
|
|
|
# vk_api_xml = files('/usr/share/vulkan/registry/vk.xml')
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2020-02-13 18:16:31 +00:00
|
|
|
|
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
|
|
|
|
2021-10-18 17:19:59 +00:00
|
|
|
imgui_options = [
|
|
|
|
'default_library=static',
|
2022-05-04 17:37:27 +00:00
|
|
|
'werror=false',
|
2021-10-18 17:19:59 +00:00
|
|
|
# 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',
|
|
|
|
'allegro5=disabled',
|
2023-10-05 16:25:05 +00:00
|
|
|
'webgpu=disabled',
|
|
|
|
'sdl_renderer=disabled'
|
2021-10-18 17:19:59 +00:00
|
|
|
]
|
|
|
|
|
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 15:50:27 +00:00
|
|
|
elif sizeof_ptr == 4
|
|
|
|
pre_args += '-DMANGOHUD_ARCH="32bit"'
|
|
|
|
endif
|
|
|
|
|
2022-07-05 10:12:23 +00:00
|
|
|
if get_option('mangoapp')
|
|
|
|
imgui_options += [
|
|
|
|
'opengl=enabled',
|
|
|
|
'glfw=enabled',
|
|
|
|
]
|
|
|
|
endif
|
2024-05-09 20:52:21 +00:00
|
|
|
dearimgui_dep = dependency('imgui', fallback: ['imgui'], required: true, default_options: imgui_options)
|
2020-05-04 10:16:09 +00:00
|
|
|
|
2023-09-21 20:05:21 +00:00
|
|
|
if is_unixy
|
2024-05-09 20:52:21 +00:00
|
|
|
implot_dep = dependency('implot', fallback: ['implot'], required: true, default_options: ['default_library=static'])
|
2023-09-21 20:05:21 +00:00
|
|
|
else
|
|
|
|
implot_dep = null_dep
|
|
|
|
implot_lib = static_library('nulllib', [])
|
|
|
|
endif
|
|
|
|
|
2024-05-09 20:52:21 +00:00
|
|
|
spdlog_options = [
|
|
|
|
'default_library=static',
|
|
|
|
'compile_library=true',
|
|
|
|
'werror=false',
|
|
|
|
'tests=disabled',
|
|
|
|
'external_fmt=disabled',
|
|
|
|
'std_format=disabled'
|
|
|
|
]
|
|
|
|
|
|
|
|
spdlog_dep = dependency('spdlog', required: false)
|
|
|
|
|
|
|
|
if get_option('use_system_spdlog').disabled() or not spdlog_dep.found()
|
|
|
|
if get_option('use_system_spdlog').enabled()
|
|
|
|
warning('spdlog depedency not found follwing back to submodule')
|
|
|
|
endif
|
|
|
|
spdlog_sp = subproject('spdlog', default_options: spdlog_options)
|
|
|
|
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
|
2021-07-16 00:28:46 +00:00
|
|
|
endif
|
|
|
|
|
2020-09-05 05:42:15 +00:00
|
|
|
if ['windows', 'mingw'].contains(host_machine.system())
|
2024-05-09 20:52:21 +00:00
|
|
|
minhook_dep = dependency('minhook', fallback: ['minhook', 'minhook_dep'], required: true)
|
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
|
|
|
|
|
2022-03-15 21:56:36 +00:00
|
|
|
if get_option('mangoapp') or get_option('mangoapp_layer')
|
2021-10-18 17:14:58 +00:00
|
|
|
glfw3_dep = dependency('glfw3')
|
2023-09-21 20:02:56 +00:00
|
|
|
glew_dep = dependency('glew')
|
2021-10-18 17:14:58 +00:00
|
|
|
endif
|
2021-09-06 06:21:10 +00:00
|
|
|
|
2022-11-29 05:18:37 +00:00
|
|
|
json_dep = dependency('nlohmann_json')
|
2020-01-29 10:23:51 +00:00
|
|
|
subdir('src')
|
2022-07-14 12:30:26 +00:00
|
|
|
|
|
|
|
if get_option('include_doc')
|
|
|
|
subdir('data')
|
|
|
|
endif
|
2022-10-26 01:52:04 +00:00
|
|
|
|
|
|
|
if get_option('tests').enabled()
|
2023-05-05 00:29:14 +00:00
|
|
|
cmocka_dep = dependency('cmocka', fallback: ['cmocka', 'cmocka_dep'])
|
2022-10-27 01:44:00 +00:00
|
|
|
|
2022-10-27 01:46:54 +00:00
|
|
|
e = executable('amdgpu', 'tests/test_amdgpu.cpp',
|
2022-10-27 01:44:00 +00:00
|
|
|
files(
|
|
|
|
'src/amdgpu.cpp',
|
|
|
|
'src/cpu.cpp',
|
|
|
|
'src/gpu.cpp',
|
|
|
|
'src/mesa/util/os_time.c',
|
|
|
|
'src/file_utils.cpp',
|
|
|
|
),
|
2023-03-03 10:46:29 +00:00
|
|
|
cpp_args: ['-DTEST_ONLY'],
|
2022-10-27 01:44:00 +00:00
|
|
|
dependencies: [
|
2024-02-12 21:54:21 +00:00
|
|
|
dep_vulkan,
|
2022-10-27 01:44:00 +00:00
|
|
|
cmocka_dep,
|
|
|
|
spdlog_dep,
|
2024-05-09 20:52:21 +00:00
|
|
|
implot_dep,
|
2022-10-27 01:44:00 +00:00
|
|
|
dearimgui_dep
|
2023-01-05 09:54:34 +00:00
|
|
|
],
|
|
|
|
include_directories: inc_common)
|
2022-10-27 01:44:00 +00:00
|
|
|
|
|
|
|
test('test amdgpu', e, workdir : meson.project_source_root() + '/tests')
|
|
|
|
|
2022-10-26 01:52:04 +00:00
|
|
|
endif
|
|
|
|
|
2022-11-15 23:31:20 +00:00
|
|
|
# install helper sripts
|
2023-10-10 08:55:45 +00:00
|
|
|
if get_option('mangoplot').enabled()
|
|
|
|
subdir('bin')
|
|
|
|
endif
|