2020-03-12 07:24:37 +00:00
|
|
|
project('MangoHud',
|
2020-01-28 04:11:05 +00:00
|
|
|
['c', 'cpp'],
|
2023-09-26 06:29:12 +00:00
|
|
|
version : 'v0.7.0',
|
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
|
|
|
]
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2023-04-02 19:57:07 +00:00
|
|
|
vkh_sp = subproject('vulkan-headers')
|
|
|
|
vk_api_xml = vkh_sp.get_variable('vulkan_api_xml')
|
|
|
|
dep_vulkan = vkh_sp.get_variable('vulkan_headers_dep')
|
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',
|
|
|
|
]
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
2023-09-21 20:05:21 +00:00
|
|
|
if is_unixy
|
|
|
|
implot_sp = subproject('implot')
|
|
|
|
implot_dep = implot_sp.get_variable('implot_dep')
|
|
|
|
implot_lib = static_library(
|
|
|
|
'implot_static',
|
|
|
|
objects: implot_sp.get_variable('implot_lib').extract_all_objects()
|
|
|
|
)
|
|
|
|
else
|
|
|
|
implot_dep = null_dep
|
|
|
|
implot_lib = static_library('nulllib', [])
|
|
|
|
endif
|
|
|
|
|
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',
|
2022-05-11 11:58:03 +00:00
|
|
|
'werror=false',
|
|
|
|
'tests=false',
|
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())
|
2023-04-09 17:06:12 +00:00
|
|
|
minhook_sp = subproject('minhook')
|
|
|
|
minhook_dep = minhook_sp.get_variable('minhook_dep')
|
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: [
|
|
|
|
cmocka_dep,
|
|
|
|
spdlog_dep,
|
|
|
|
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
|
|
|
|
subdir('bin')
|