summaryrefslogtreecommitdiff
path: root/meson.build
blob: c6b0ae6e0d3ce95e5f94f65308c77452a40b8331 (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
project('mauri', ['cpp', 'c'], version: '0.14',
  default_options: ['warning_level=2', 'cpp_std=c++17', 'c_std=c99'],
  license: 'GPL-3.0-only')

compiler = meson.get_compiler('cpp')
cmake = import('cmake')

is_debug = get_option('debug')
is_windows = host_machine.system() == 'windows'

mauri_src = [
  'src/mauri.cc',
  'src/assets.cc',
  'src/context.cc',
  'src/gl.cc',
  'src/shader.cc',
  'src/engine.cc',
  'src/texture.cc',
  'src/objects/scene.cc',
  'src/objects/object.cc',
  'src/objects/model.cc',
  'src/objects/effect.cc',
  'src/objects/material.cc',
  'src/objects/pass.cc'
]
mauri_deps = []
mauri_cpp_args = []
mauri_link_args = []

alabaster = subproject('libalabaster').get_variable('alabaster')
naunet = subproject('libnaunet', default_options: [
  get_option('taro').enabled() ? 'event-loop=enabled' : 'event-loop=disabled',
  'curl=disabled',
  'json=enabled'
]).get_variable('naunet')
stela = subproject('stela', default_options: [
  'api=gl',
  'window='+get_option('window'),
  'poll=inline',
  'event-buffer=false',
  'pause=false'
]).get_variable('stela')
mauri_deps += [alabaster, naunet, stela]

janus = subproject('janus').get_variable('janus')
json = dependency('nlohmann_json')
lz4 = dependency('liblz4')
if not (compiler.check_header('stb/stb_image.h') and compiler.check_header('stb/stb_image_write.h'))
  stb = subproject('stb').get_variable('stb')
  mauri_deps += [stb]
  mauri_cpp_args += ['-DMAURI_LOCAL_STB']
endif
s3tc = subproject('s3tc-dxt-decompression').get_variable('s3tc')
glm = dependency('glm', required: false, allow_fallback: false)
if not glm.found()
  glm_opts = cmake.subproject_options()
  glm_opts.add_cmake_defines({ 'CMAKE_BUILD_TYPE': is_debug ? 'Debug' : 'Release' })
  glm = cmake.subproject('glm', options: glm_opts).dependency('glm')
endif
mauri_deps += [janus, json, lz4, s3tc, glm]

if get_option('audio').enabled()
  error('Audio support currently unimplemented.')
  fftw3 = dependency('fftw3')
  mauri_deps += [fftw3]
  mauri_cpp_args += ['-DMAURI_HAVE_AUDIO']
endif

if is_windows and meson.is_cross_build()
  mauri_link_args += ['-static', '-static-libgcc', '-static-libstdc++', '-municode', '-mwindows']
endif

executable('mauri', mauri_src, dependencies: mauri_deps,
  cpp_args: mauri_cpp_args, link_args: mauri_link_args, install: true)

if get_option('taro').enabled()
  subdir('taro')
endif