project( 'yasl', 'c', meson_version: '>=1.6.0', version: '0.1.0', default_options: [ 'c_std=c23', 'warning_level=2', 'b_lto=false', ], ) cc = meson.get_compiler('c') system = host_machine.system() inc = include_directories('include', 'src') deps = [] sources = [] has_wayland = false has_x11 = false has_cocoa = system == 'darwin' if system == 'linux' wl_client = dependency('wayland-client', required: get_option('wayland')) wl_cursor = dependency('wayland-cursor', required: get_option('wayland')) xkbcommon = dependency('xkbcommon', required: get_option('wayland')) has_wayland = wl_client.found() and wl_cursor.found() and xkbcommon.found() x11 = dependency('x11', required: get_option('x11')) x11_xkb = dependency('xkbcommon', required: get_option('x11')) has_x11 = x11.found() and x11_xkb.found() if has_x11 deps += [x11, x11_xkb] endif threads = dependency('threads') m_dep = cc.find_library('m', required: false) rt_dep = cc.find_library('rt', required: false) deps += [threads, m_dep, rt_dep] if has_wayland deps += [wl_client, wl_cursor, xkbcommon] endif elif system == 'darwin' add_languages('objc') deps += [ dependency('appleframeworks', modules: ['AppKit', 'Metal', 'QuartzCore']), ] else error('YASL supports Linux and macOS.') endif if not has_wayland and not has_x11 and not has_cocoa error('Enable at least one window backend.') endif add_project_arguments( '-DYASL_HAS_WAYLAND=' + (has_wayland ? '1' : '0'), '-DYASL_HAS_X11=' + (has_x11 ? '1' : '0'), '-DYASL_HAS_COCOA=' + (has_cocoa ? '1' : '0'), language: has_cocoa ? ['c', 'objc'] : ['c'], ) if has_cocoa add_project_arguments('-fblocks', language: 'objc') endif subdir('src') yasl_lib = both_libraries( 'yasl', sources, include_directories: inc, dependencies: deps, gnu_symbol_visibility: 'hidden', install: true, ) install_headers( 'include/yasl/yasl.h', 'include/yasl/timing.h', 'include/yasl/loop.h', 'include/yasl/native.h', subdir: 'yasl', ) pkg = import('pkgconfig') pkg.generate( yasl_lib.get_shared_lib(), name: 'yasl', description: 'Yet Another Surface Library - minimal, modern desktop window surface abstraction', version: meson.project_version(), subdirs: '.', ) yasl_dep = declare_dependency( link_with: yasl_lib.get_static_lib(), include_directories: include_directories('include'), dependencies: deps, ) meson.override_dependency('yasl', yasl_dep) executable( 'yasl-example', 'examples/simple_window.c', include_directories: inc, link_with: yasl_lib.get_shared_lib(), dependencies: deps, ) subdir('tests')