summaryrefslogtreecommitdiff
path: root/meson.build
blob: 258661beac9b438c74772db725f1c2e300a5c25e (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
project('jacktrip', ['cpp','c'],
		default_options: ['cpp_std=c++17','warning_level=2'])

if get_option('profile') == 'development'
  application_id = 'org.jacktrip.JackTrip.Devel'
  name_suffix = ' (Development Snapshot)'
else
  application_id = 'org.jacktrip.JackTrip'
  name_suffix = ''
endif

qt5 = import('qt5')
cmake = import('cmake')

compiler = meson.get_compiler('cpp')

defines = ['-DWAIRTOHUB']
c_defines = []
if host_machine.system() == 'linux'
	defines += '-D__LINUX__'
elif host_machine.system() == 'darwin'
	defines += '-D__MAC_OSX__'
elif host_machine.system() == 'windows'
	defines += '-D__WIN_32__'
	defines += '-D_WIN32_WINNT=0x0600'
	defines += '-DWIN32_LEAN_AND_MEAN'
	defines += '-DNOMINMAX'
endif

incdir = include_directories('externals/weakjack')

src = [	'src/DataProtocol.cpp',
	'src/JackTrip.cpp',
	'src/AudioTester.cpp',
	'src/jacktrip_globals.cpp',
	'src/JackTripWorker.cpp',
	'src/LoopBack.cpp',
	'src/PacketHeader.cpp',
	'src/RingBuffer.cpp',
	'src/JitterBuffer.cpp',
	'src/PoolBuffer.cpp',
	'src/Settings.cpp',
	'src/UdpDataProtocol.cpp',
	'src/UdpHubListener.cpp',
	'src/AudioInterface.cpp',
	'src/Compressor.cpp',
	'src/Limiter.cpp',
	'src/Reverb.cpp',
	'src/main.cpp',
	'src/SslServer.cpp',
	'src/Auth.cpp']

moc_h = ['src/DataProtocol.h',
	'src/JackTrip.h',
	'src/JackTripWorker.h',
	'src/PacketHeader.h',
	'src/Settings.h',
	'src/UdpDataProtocol.h',
	'src/UdpHubListener.h',
	'src/Auth.h',
	'src/SslServer.h']

ui_h = []
qres = []

deps = [dependency('threads')]
jack_dep = dependency('jack', required: get_option('jack'))
if not jack_dep.found()
	defines += '-D__NO_JACK__'
else
	src += 	['src/JackAudioInterface.cpp',
		'src/JMess.cpp',
		'src/Patcher.cpp']
	moc_h += ['src/Patcher.h']
	if get_option('weakjack') == true
		src += 'externals/weakjack/weak_libjack.c'
		defines += '-DUSE_WEAK_JACK'
		c_defines += '-DUSE_WEAK_JACK'
		deps += jack_dep.partial_dependency(includes: true)
		deps += compiler.find_library('dl', required : false)
	else
		deps += jack_dep
	endif
endif

if get_option('nogui') == true
	defines += '-DNO_GUI'
	qt5_dep = dependency('qt5', modules: ['Core', 'Network'], include_type: 'system')
else
	qt5_dep = dependency('qt5', modules: ['Core', 'Gui', 'Network', 'Widgets'], include_type: 'system')
	src += ['src/gui/qjacktrip.cpp',
		'src/gui/about.cpp',
		'src/gui/messageDialog.cpp',
		'src/gui/textbuf.cpp']
	ui_h += ['src/gui/qjacktrip.ui',
		'src/gui/messageDialog.ui',
		'src/gui/about.ui']
	moc_h += ['src/gui/about.h',
		'src/gui/qjacktrip.h',
		'src/gui/messageDialog.h',
		'src/gui/textbuf.h']
	qres = ['src/gui/qjacktrip.qrc']
endif
deps += qt5_dep

prepro_files = qt5.preprocess(moc_headers : moc_h, ui_files : ui_h, qresources : qres)

# TODO: QT_OPENSOURCE should only be defined for open source Qt distribution
# in QMake this can be checked with QT_EDITION == 'OpenSource'
defines += '-DQT_OPENSOURCE'

rtaudio_dep = dependency('rtaudio', required: get_option('rtaudio'))
if rtaudio_dep.found() == true
	defines += '-D__RT_AUDIO__'
	src += 'src/RtAudioInterface.cpp'
	deps += rtaudio_dep
endif

if host_machine.system() == 'windows'
	deps += compiler.find_library('ws2_32', required: true)
endif

if compiler.get_id() == 'msvc'
	opt_var = cmake.subproject_options()
	if get_option('buildtype') == 'release'
		opt_var.add_cmake_defines({'CMAKE_BUILD_TYPE': 'Release'})
	else
		opt_var.add_cmake_defines({'CMAKE_BUILD_TYPE': 'Debug'})
	endif
	wingetopt = cmake.subproject('wingetopt', options: opt_var)
	deps += wingetopt.dependency('wingetopt')
endif

if host_machine.system() == 'darwin'
	src += ['src/gui/NoNap.mm']
	# Adding CoreAudio here is a workaround and should be removed
	# when https://github.com/thestk/rtaudio/issues/302 is fixed
	# and arrived in all common package managers
	# Check at 2022-07-30
	apple_dep = dependency('appleframeworks', modules : ['foundation','coreaudio'])
	deps += apple_dep
	add_languages('objcpp')
endif

subdir('linux')

jacktrip = executable('jacktrip', src, prepro_files, include_directories: incdir, dependencies: deps, c_args: c_defines, cpp_args: defines, install: true )

help2man = find_program('help2man', required: false)
if not (host_machine.system() == 'windows')
	if help2man.found()
		help2man_opts = [
			'--no-info',
			'--section=1']
		custom_target('jacktrip.1',
			output: 'jacktrip.1',
			command: [help2man, help2man_opts, '--output=@OUTPUT@', jacktrip],
			install: true,
			install_dir: get_option('mandir') / 'man1')
	endif
endif

summary({'JACK': jack_dep.found(),
	'Weak JACK Linking': get_option('weakjack'),
	'RtAudio': rtaudio_dep.found()}, bool_yn: true, section: 'Audio Backends')

summary({'Application ID': application_id,
	'GUI': not get_option('nogui'),
	'WAIR': get_option('wair'),
	'Manpage': help2man.found()}, bool_yn: true, section: 'Configuration')