summaryrefslogtreecommitdiff
path: root/src/lib/xiph/meson.build
blob: 7f56c76e06a13465669c14d4cc0f3be82af94269 (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
134
135
136
137
138
139
140
libflac_dep = dependency('flac', version: '>= 1.2', required: get_option('flac'))
libopus_dep = dependency('opus', required: get_option('opus'))

if get_option('tremor').enabled()
  # no libvorbis if Tremor was explicitly enabled
  libvorbis_dep = dependency('', required: false)
else
  libvorbis_dep = dependency('vorbis', required: get_option('vorbis'))
endif

if libvorbis_dep.found()
  # no Tremor if libvorbis is used
  libvorbisidec_dep = dependency('', required: false)
else
  # attempt to auto-detect Tremor only if libvorbis was disabled or not found
  libvorbisidec_dep = dependency('vorbisidec', required: get_option('tremor'))
endif

if get_option('vorbis').enabled() and get_option('tremor').enabled()
	error('Cannot build both, the Vorbis decoder AND the Tremor (Vorbis fixed-point) decoder')
endif

libvorbisenc_dep = dependency('', required: false)
if need_encoder and not get_option('vorbisenc').disabled()
  if libvorbis_dep.found()
    libvorbisenc_dep = dependency('vorbisenc', required: get_option('vorbisenc'))
  elif get_option('vorbisenc').enabled()
    error('Cannot build the Vorbis encoder without the Vorbis decoder')
  else
    message('Disabling the Vorbis encoder because the Vorbis decoder is disabled as well')
  endif
endif

if libopus_dep.found() or libvorbis_dep.found() or libvorbisenc_dep.found() or libvorbisidec_dep.found()
  libogg_dep = dependency('ogg')
else
  libogg_dep = dependency('', required: false)
endif

if not libogg_dep.found() and not libflac_dep.found()
  xiph_dep = dependency('', required: false)
  ogg_dep = dependency('', required: false)
  vorbis_dep = dependency('', required: false)
  flac_dep = dependency('', required: false)
  subdir_done()
endif

xiph_sources = [
  'ScanVorbisComment.cxx',
  'VorbisPicture.cxx',
  'XiphTags.cxx',
]

if libvorbis_dep.found() or libvorbisidec_dep.found()
  xiph_sources += 'VorbisComments.cxx'
endif

xiph = static_library(
  'xiph',
  xiph_sources,
  include_directories: inc,
  dependencies: [
    libvorbis_dep,
  ],
)

xiph_dep = declare_dependency(
  link_with: xiph,
)

if libogg_dep.found()
  ogg = static_library(
    'ogg',
    'OggVisitor.cxx',
    'OggSyncState.cxx',
    'OggFind.cxx',
    'OggPacket.cxx',
    include_directories: inc,
    dependencies: [
      libogg_dep,
    ],
  )

  ogg_dep = declare_dependency(
    link_with: ogg,
    dependencies: [
      xiph_dep,
      libogg_dep,
    ],
  )
else
  ogg_dep = dependency('', required: false)
endif

if libvorbis_dep.found() or libvorbisidec_dep.found()
  vorbis = static_library(
    'vorbis',
    'VorbisComments.cxx',
    include_directories: inc,
    dependencies: [
      libvorbis_dep,
      libvorbisidec_dep,
    ],
  )

  vorbis_dep = declare_dependency(
    link_with: vorbis,
    dependencies: [
      ogg_dep,
      libvorbis_dep,
      libvorbisidec_dep,
    ],
  )
else
  vorbis_dep = dependency('', required: false)
endif

if libflac_dep.found()
  flac = static_library(
    'flac',
    'FlacIOHandle.cxx',
    'FlacMetadataChain.cxx',
    'FlacStreamMetadata.cxx',
    include_directories: inc,
    dependencies: [
      libflac_dep,
      log_dep,
    ],
  )

  flac_dep = declare_dependency(
    link_with: flac,
    dependencies: [
      xiph_dep,
      libflac_dep,
    ],
  )
else
  flac_dep = dependency('', required: false)
endif