summaryrefslogtreecommitdiff
path: root/meson.build
blob: 2126ef228ae4342c97b7fa01aedb77767059f326 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
project('camu', ['c', 'cpp'], # Marking cpp here is required for subproject cross-builds.
  version: '0.01',
  meson_version: '>=0.63.0', # Wrap diff_files (0.63.0).
  default_options: ['warning_level=2', 'c_std=c99'],
  license: 'GPL-3.0-only')

# Fail early if 'Compiler for build machine not found'.
add_languages('c', 'cpp', native: true)

compiler = meson.get_compiler('c')

is_debug = get_option('debug')
is_minsize = get_option('optimization') == 's'
is_linux = host_machine.system() == 'linux'
is_windows = host_machine.system() == 'windows'
is_msvc = compiler.get_id() == 'msvc' or compiler.get_id() == 'clang-cl'
is_android = host_machine.system() == 'android'
is_static_shared_lib = is_android

cmake = import('cmake')
cmake_reltype = is_minsize ? 'MinSizeRel' : 'Release'

need_server = get_option('server').enabled()
need_client = get_option('client').enabled()
need_sink = get_option('sink').enabled()
no_video = get_option('sink-no-video')
if 'cmsrv' in get_option('fruits')
  if get_option('server').disabled()
    error('cmsrv requires the server component.')
  endif
  need_server = true
endif
if 'cmc' in get_option('fruits')
  if get_option('client').disabled()
    error('cmc requires the client component.')
  endif
  need_client = true
endif
if 'cmv' in get_option('fruits')
  if get_option('sink').disabled()
    error('cmv requires the sink component.')
  endif
  if not get_option('sink-only')
    if get_option('server').disabled()
      error('cmv requires the server component unless in a sink-only configuration.')
    endif
    need_server = true
  endif
  need_sink = true
endif

alabaster = subproject('libalabaster')
naunet_opts = []
if need_server and 'http' in get_option('sources')
  naunet_opts += ['curl=enabled']
endif
if get_option('portal').enabled()
  naunet_opts += ['json=enabled']
endif
naunet = subproject('libnaunet', default_options: naunet_opts)
naunet_has_curl = naunet.get_variable('naunet_has_curl')
naunet_has_mmap = naunet.get_variable('naunet_has_mmap')
common_deps = [alabaster.get_variable('alabaster'), naunet.get_variable('naunet')]

window = get_option('window')
if window == 'auto'
  if is_windows
    window = 'win32'
  elif is_android
    window = 'glfm'
  else
    window = 'wayland'
  endif
endif
renderer_api = get_option('renderer-api')
if renderer_api == 'auto'
  if is_windows
    renderer_api = 'dx11'
  elif is_android
    renderer_api = 'gl'
  else
    renderer_api = 'vulkan'
  endif
endif
stela_opts = ['poll=inline', 'event-buffer=false', 'pause=true', 'window=' + window]
if renderer_api == 'vulkan'
  stela_opts += ['api=vulkan']
elif renderer_api == 'dx11'
  stela_opts += ['api=dx11']
elif renderer_api in ['gl', 'gl-rpi']
  stela_opts += [is_android ? 'api=gles' : 'api=gl']
  if renderer_api == 'gl-rpi'
    stela_opts += ['egl-brcm=true']
  endif
endif
stela = subproject('stela', default_options: stela_opts).get_variable('stela')

subdir('src/util')
common_deps += [util]

subdir('src/cache')
subdir('src/codec')
subdir('src/liana')

if get_option('portal').enabled()
  subdir('src/portal')
endif

if need_server
  subdir('src/server')
endif

if need_client
  subdir('src/libclient')
endif

if need_sink
  subdir('src/buffer')
  subdir('src/mixer')
  if not no_video
    subdir('src/render')
    subdir('src/screen')
  endif
  subdir('src/libsink')
endif

if get_option('fruits') != []
  subdir('src/fruits')
endif

if get_option('tests').allowed() and not meson.is_subproject()
  subdir('tests')
endif