146 lines
3.6 KiB
Meson
146 lines
3.6 KiB
Meson
# Modified Meson WrapDB file
|
|
project(
|
|
'glfw',
|
|
'c',
|
|
version: '3.3.10',
|
|
license: 'Zlib',
|
|
default_options: ['b_ndebug=if-release', 'c_std=c99', 'warning_level=0'],
|
|
meson_version: '>=0.58.0',
|
|
)
|
|
#@ Project variables
|
|
sys_os = host_machine.system()
|
|
sys_cc = meson.get_compiler('c')
|
|
opt_libdir = get_option('libdir')
|
|
is_posix = sys_os != 'windows'
|
|
|
|
if get_option('default_library') != 'static'
|
|
add_project_arguments('-D_GLFW_BUILD_DLL', language: 'c')
|
|
endif
|
|
|
|
if sys_os == 'windows'
|
|
opt_display = 'win32'
|
|
elif sys_os == 'darwin'
|
|
opt_display = 'cocoa'
|
|
else
|
|
opt_display = 'x11'
|
|
endif
|
|
|
|
### Dependencies ###
|
|
deps = []
|
|
#@ Backend API
|
|
# X11
|
|
if opt_display == 'x11'
|
|
foreach x : ['x11', 'xrandr', 'xinerama', 'xcursor', 'xi', 'xkbcommon']
|
|
deps += dependency(x, required: true)
|
|
endforeach
|
|
# Win32
|
|
elif opt_display == 'win32'
|
|
if sys_os != 'windows'
|
|
error('Non Windows is unsupportred')
|
|
endif
|
|
# Cocoa
|
|
elif opt_display == 'cocoa'
|
|
if sys_os != 'darwin'
|
|
error('Non macOS is unsupported')
|
|
endif
|
|
deps += dependency('appleframeworks', modules: ['Cocoa', 'CoreFoundation', 'IOKit'])
|
|
endif
|
|
|
|
#@ System Dependencies
|
|
foreach l : ['m', 'rt']
|
|
deps += sys_cc.find_library(l, required: false)
|
|
endforeach
|
|
if meson.version().version_compare('>= 0.62')
|
|
deps += dependency('dl', required: false)
|
|
else
|
|
deps += sys_cc.find_library('dl', required: false)
|
|
endif
|
|
deps += dependency('threads')
|
|
|
|
### Configuration ###
|
|
cfg_data = configuration_data()
|
|
foreach d : ['osmesa', 'x11', 'wayland', 'win32', 'cocoa']
|
|
cfg_data.set('_GLFW_' + d.to_upper(), opt_display == d)
|
|
endforeach
|
|
cfg_file = configure_file(configuration: cfg_data, output: 'glfw_config.h')
|
|
|
|
### Targets ###
|
|
#@ Primary target:
|
|
## GLFW library
|
|
# Common files
|
|
s_common = files('src/context.c', 'src/init.c', 'src/input.c', 'src/monitor.c', 'src/vulkan.c', 'src/window.c')
|
|
s_common += cfg_file
|
|
|
|
# Backend files
|
|
if opt_display == 'x11'
|
|
s_display = files(
|
|
'src/egl_context.c',
|
|
'src/glx_context.c',
|
|
'src/osmesa_context.c',
|
|
'src/posix_thread.c',
|
|
'src/posix_time.c',
|
|
'src/x11_init.c',
|
|
'src/x11_monitor.c',
|
|
'src/x11_window.c',
|
|
'src/xkb_unicode.c',
|
|
'src/@0@_joystick.c'.format(sys_os == 'linux' ? 'linux' : 'null'),
|
|
)
|
|
elif opt_display == 'win32'
|
|
s_display = files(
|
|
'src/egl_context.c',
|
|
'src/osmesa_context.c',
|
|
'src/wgl_context.c',
|
|
'src/win32_init.c',
|
|
'src/win32_joystick.c',
|
|
'src/win32_monitor.c',
|
|
'src/win32_thread.c',
|
|
'src/win32_time.c',
|
|
'src/win32_window.c',
|
|
)
|
|
elif opt_display == 'cocoa'
|
|
add_languages('objc', native: false)
|
|
s_display = files(
|
|
'src/cocoa_init.m',
|
|
'src/cocoa_joystick.m',
|
|
'src/cocoa_monitor.m',
|
|
'src/cocoa_time.c',
|
|
'src/cocoa_window.m',
|
|
'src/egl_context.c',
|
|
'src/nsgl_context.m',
|
|
'src/osmesa_context.c',
|
|
'src/posix_thread.c',
|
|
)
|
|
add_project_arguments('-D_GLFW_USE_CONFIG_H', language: 'objc')
|
|
if host_machine.system() == 'darwin'
|
|
add_project_arguments('-D_DARWIN_C_SOURCE', language: 'objc')
|
|
endif
|
|
endif
|
|
srcfiles = [s_common, s_display]
|
|
incdirs = include_directories('include', 'src')
|
|
|
|
#@ Flags
|
|
add_project_arguments('-D_GLFW_USE_CONFIG_H', language: 'c')
|
|
if host_machine.system() == 'darwin'
|
|
add_project_arguments('-D_DARWIN_C_SOURCE', language: 'c')
|
|
endif
|
|
|
|
c_args = ['-Wno-everything']
|
|
|
|
# Build
|
|
glfw_lib = library(
|
|
'glfw3',
|
|
srcfiles,
|
|
include_directories: incdirs,
|
|
dependencies: deps,
|
|
version: meson.project_version(),
|
|
build_by_default: true,
|
|
pic: true,
|
|
c_args: c_args,
|
|
)
|
|
glfw_dep = declare_dependency(
|
|
include_directories: incdirs,
|
|
link_with: glfw_lib,
|
|
)
|
|
|
|
meson.override_dependency('glfw3', glfw_dep)
|