MangoHud/meson.build

287 lines
7.5 KiB
Meson
Raw Normal View History

2020-03-12 07:24:37 +00:00
project('MangoHud',
['c', 'cpp'],
2022-05-04 13:11:27 +00:00
version : 'v0.6.7',
license : 'MIT',
meson_version: '>=0.60.0',
default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++14', 'warning_level=2']
)
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
prog_python = import('python').find_installation('python3', modules: ['mako'])
2020-01-30 17:52:15 +00:00
null_dep = dependency('', required : false)
2020-05-02 16:39:39 +00:00
mangohud_version = vcs_tag(
command: ['git', 'describe', '--tags', '--dirty=+'],
input: 'version.h.in',
output: 'version.h')
pre_args = [
'-D__STDC_CONSTANT_MACROS',
'-D__STDC_FORMAT_MACROS',
'-D__STDC_LIMIT_MACROS',
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
'-DSPDLOG_COMPILED_LIB'
]
# Define DEBUG for debug builds only (debugoptimized is not included on this one)
if get_option('buildtype') == 'debug'
pre_args += '-DDEBUG'
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE'
2020-01-29 10:23:51 +00:00
else
pre_args += '-DNDEBUG'
pre_args += '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_' + get_option('loglevel').to_upper()
endif
# TODO: this is very incomplete
2020-09-05 05:42:39 +00:00
is_unixy = false
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
endif
if get_option('glibcxx_asserts')
pre_args += '-D_GLIBCXX_ASSERTIONS'
endif
# 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
if dep_x11.found()
vulkan_wsi_args += ['-DVK_USE_PLATFORM_XLIB_KHR']
vulkan_wsi_deps += dep_x11.partial_dependency(compile_args : true, includes : true)
endif
if dep_wayland_client.found()
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()
error('At least one of "with_x11" and "with_wayland" should be enabled')
endif
inc_common = [
include_directories('include'),
]
dep_vulkan = dependency('vulkan', required: get_option('use_system_vulkan'))
dep_pthread = dependency('threads')
# Check for generic C arguments
c_args = []
foreach a : ['-Werror=implicit-function-declaration',
'-Werror=missing-prototypes', '-Werror=return-type',
'-Werror=incompatible-pointer-types',
'-Wno-unused-parameter', '-Qunused-arguments',
'-fno-math-errno', '-fno-trapping-math']
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',
'-Wno-unused-parameter', '-Qunused-arguments',
'-fno-math-errno', '-fno-trapping-math']
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.
foreach a : ['non-virtual-dtor', 'missing-field-initializers', 'format-truncation']
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
else
2020-09-05 05:42:39 +00:00
dep_dl = null_dep
dep_rt = null_dep
endif
if dep_vulkan.found()
datadir = get_option('vulkan_datadir')
if datadir == ''
datadir = get_option('datadir')
endif
if not datadir.startswith('/')
datadir = get_option('prefix') / datadir
endif
vk_api_xml = files(datadir / 'vulkan/registry/vk.xml')
else
vkh_sp = subproject('vulkan-headers')
vk_api_xml = vkh_sp.get_variable('vulkan_api_xml')
dep_vulkan = vkh_sp.get_variable('vulkan_headers_dep')
endif
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
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',
'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',
'marmalade=disabled',
'allegro5=disabled',
]
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)
dearimgui_dep = dearimgui_sp.get_variable('imgui_dep')
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',
'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())
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
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')
json_dep = dependency('nlohmann_json')
2021-10-18 17:14:58 +00:00
endif
2021-09-06 06:21:10 +00:00
2020-01-29 10:23:51 +00:00
subdir('src')
if get_option('include_doc')
subdir('data')
endif