blob: 23a2630d99a62260ea922ddaa302640bc43907c0 [file] [log] [blame]
James Kuszmaul64391362021-01-17 11:32:00 -08001# Project definition
2project('rawrtcdc', 'c',
3 version: '0.1.3',
4 default_options: ['c_std=c99'],
5 meson_version: '>=0.46.0')
6
7# Set compiler warning flags
8compiler = meson.get_compiler('c')
9compiler_args = compiler.get_supported_arguments([
10 '-Wall',
11 '-Wmissing-declarations',
12 '-Wmissing-prototypes',
13 '-Wstrict-prototypes',
14 '-Wbad-function-cast',
15 '-Wsign-compare',
16 '-Wnested-externs',
17 '-Wshadow',
18 '-Waggregate-return',
19 '-Wcast-align',
20 '-Wextra',
21 '-Wold-style-definition',
22 '-Wdeclaration-after-statement',
23 '-Wuninitialized',
24 '-Wshorten-64-to-32',
25 '-pedantic',
26])
27add_project_arguments(compiler_args, language: 'c')
28
29# Configuration
30configuration = configuration_data()
31
32# Dependency: re
33# Note: We need to force using our own fork until re has accepted all our patches
34re_dep = dependency('librawrre',
35 version: '>=0.6.0',
36 fallback: ['re', 're_dep'],
37 required: true)
38
39# Dependency: usrsctp
40sctp_debug = get_option('debug_level') >= 7
41usrsctp_dep = dependency('usrsctp',
42 version: ['>=1.0.0', '<2'],
43 fallback: ['usrsctp', 'usrsctp_dep'],
44 default_options: [
45 'sctp_build_programs=false',
46 'sctp_debug=@0@'.format(sctp_debug),
47 'sctp_inet=false',
48 'sctp_inet6=false',
49 ],
50 required: true)
51
52# Dependency: rawrtcc
53rawrtcc_dep = dependency('rawrtcc',
54 version: '>=0.1.3',
55 fallback: ['rawrtcc', 'rawrtcc_dep'],
56 required: true)
57
58# Dependencies list
59dependencies = [
60 re_dep,
61 usrsctp_dep,
62 rawrtcc_dep,
63]
64
65# Feature: Hardware CRC32-C (requires SSE 4.2)
66# Note: If it compiles, it only enables the check for SSE 4.2 at runtime.
67code = '''
68#include <stdint.h>
69int main(int argc, char* argv[]) {
70 uint32_t eax, ecx;
71 eax = 1;
72 __asm__("cpuid" : "=c"(ecx) : "a"(eax) : "%ebx", "%edx");
73 return 0;
74}
75'''
76have_cpuid = compiler.compiles(code) and host_machine.cpu() == 'x86_64'
77configuration.set10('RAWRTCDC_ENABLE_SSE42_CRC32C', have_cpuid)
78
79# Options
80configuration.set10('RAWRTCDC_HAVE_SCTP_REDIRECT_TRANSPORT', get_option('sctp_redirect_transport'))
81
82# Version
83version = meson.project_version()
84version_array = version.split('.')
85configuration.set_quoted('RAWRTCDC_VERSION', version)
86configuration.set('RAWRTCDC_VERSION_MAJOR', version_array[0])
87configuration.set('RAWRTCDC_VERSION_MINOR', version_array[1])
88configuration.set('RAWRTCDC_VERSION_PATCH', version_array[2])
89
90# Set debug level
91configuration.set('RAWRTC_DEBUG_LEVEL', get_option('debug_level'))
92
93# Includes
94include_dir = include_directories('include')
95subdir('include')
96
97# Sources
98subdir('src')
99
100# Build library
101rawrtcdc = library(meson.project_name(), sources,
102 dependencies: dependencies,
103 include_directories: include_dir,
104 install: true,
105 version: version)
106
107# Declare dependency
108rawrtcdc_dep = declare_dependency(
109 include_directories: include_dir,
110 link_with: rawrtcdc)
111
112# Generate pkg-config file
113pkg = import('pkgconfig')
114pkg.generate(rawrtcdc,
115 name: meson.project_name(),
116 description: 'A standalone WebRTC and ORTC data channel implementation.',
117 url: 'https://github.com/rawrtc/rawrtc-data-channel')