James Kuszmaul | 6439136 | 2021-01-17 11:32:00 -0800 | [diff] [blame] | 1 | # Project definition |
| 2 | project('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 |
| 8 | compiler = meson.get_compiler('c') |
| 9 | compiler_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 | ]) |
| 27 | add_project_arguments(compiler_args, language: 'c') |
| 28 | |
| 29 | # Configuration |
| 30 | configuration = configuration_data() |
| 31 | |
| 32 | # Dependency: re |
| 33 | # Note: We need to force using our own fork until re has accepted all our patches |
| 34 | re_dep = dependency('librawrre', |
| 35 | version: '>=0.6.0', |
| 36 | fallback: ['re', 're_dep'], |
| 37 | required: true) |
| 38 | |
| 39 | # Dependency: usrsctp |
| 40 | sctp_debug = get_option('debug_level') >= 7 |
| 41 | usrsctp_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 |
| 53 | rawrtcc_dep = dependency('rawrtcc', |
| 54 | version: '>=0.1.3', |
| 55 | fallback: ['rawrtcc', 'rawrtcc_dep'], |
| 56 | required: true) |
| 57 | |
| 58 | # Dependencies list |
| 59 | dependencies = [ |
| 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. |
| 67 | code = ''' |
| 68 | #include <stdint.h> |
| 69 | int 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 | ''' |
| 76 | have_cpuid = compiler.compiles(code) and host_machine.cpu() == 'x86_64' |
| 77 | configuration.set10('RAWRTCDC_ENABLE_SSE42_CRC32C', have_cpuid) |
| 78 | |
| 79 | # Options |
| 80 | configuration.set10('RAWRTCDC_HAVE_SCTP_REDIRECT_TRANSPORT', get_option('sctp_redirect_transport')) |
| 81 | |
| 82 | # Version |
| 83 | version = meson.project_version() |
| 84 | version_array = version.split('.') |
| 85 | configuration.set_quoted('RAWRTCDC_VERSION', version) |
| 86 | configuration.set('RAWRTCDC_VERSION_MAJOR', version_array[0]) |
| 87 | configuration.set('RAWRTCDC_VERSION_MINOR', version_array[1]) |
| 88 | configuration.set('RAWRTCDC_VERSION_PATCH', version_array[2]) |
| 89 | |
| 90 | # Set debug level |
| 91 | configuration.set('RAWRTC_DEBUG_LEVEL', get_option('debug_level')) |
| 92 | |
| 93 | # Includes |
| 94 | include_dir = include_directories('include') |
| 95 | subdir('include') |
| 96 | |
| 97 | # Sources |
| 98 | subdir('src') |
| 99 | |
| 100 | # Build library |
| 101 | rawrtcdc = library(meson.project_name(), sources, |
| 102 | dependencies: dependencies, |
| 103 | include_directories: include_dir, |
| 104 | install: true, |
| 105 | version: version) |
| 106 | |
| 107 | # Declare dependency |
| 108 | rawrtcdc_dep = declare_dependency( |
| 109 | include_directories: include_dir, |
| 110 | link_with: rawrtcdc) |
| 111 | |
| 112 | # Generate pkg-config file |
| 113 | pkg = import('pkgconfig') |
| 114 | pkg.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') |