meson.build 7.79 KB
Newer Older
1
project('jami-daemon', ['c', 'cpp'],
2
        version: '9.5.0',
3
        license: 'GPL3+',
Adrien Béraud's avatar
Adrien Béraud committed
4
        default_options: ['cpp_std=gnu++17', 'buildtype=debugoptimized'],
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
        meson_version:'>= 0.54'
       )

modpkgconfig = import('pkgconfig')
modcmake = import('cmake')

#################################################
# Required dependencies
#################################################
depthreads = dependency('threads')
depopendht = dependency('opendht', version: '>= 2.1.0')
depgnutls = dependency('gnutls', version: '>= 3.6.7')
deplibpjproject = dependency('libpjproject')
deplibsecp256k1 = dependency('libsecp256k1', version: '>= 0.1')
deplibavcodec = dependency('libavcodec', version: '>= 56.60.100')
deplibavfilter = dependency('libavfilter', version: '>= 5.40.101')
deplibavdevice = dependency('libavdevice', version: '>= 56.4.100')
deplibavformat = dependency('libavformat', version: '>= 56.40.101')
deplibswscale = dependency('libswscale', version: '>= 3.1.101')
deplibswresample = dependency('libswresample', version: '>= 1.2.101')
deplibavutil = dependency('libavutil', version: '>= 55.75.100')
depspeex = dependency('speex')
depspeexdsp = dependency('speexdsp')

depyamlcpp = dependency('yaml-cpp', version: '>= 0.5.1', required: false)
if not depyamlcpp.found()
    depyamlcpp = modcmake.subproject('yaml-cpp', cmake_options: [
Vladimir Stoiakin's avatar
Vladimir Stoiakin committed
32 33
        '-DCMAKE_BUILD_TYPE=Release',
        '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
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
        '-DYAML_CPP_BUILD_TOOLS=OFF',
        '-DYAML_CPP_BUILD_TESTS=OFF',
        '-DYAML_CPP_BUILD_CONTRIB=OFF',
        '-DBUILD_SHARED_LIBS=OFF'
    ]).dependency('yaml-cpp')
endif

depjsoncpp = dependency('jsoncpp', version: '>= 1.6.5',
                        fallback: ['jsoncpp', 'jsoncpp_dep'], default_options: ['default_library=static'])
depzlib = dependency('zlib', fallback: ['zlib', 'zlib_dep'], default_options: ['default_library=static'])

if get_option('interfaces').contains('dbus')
    depdbuscpp = dependency('dbus-c++-1')
    progdbusxxxml2cpp = find_program('dbusxx-xml2cpp', native: true)
endif

if get_option('interfaces').contains('nodejs')
    progswig = find_program('swig', native: true)
    prognodegyp = find_program('node-gyp', native: true)
endif

if get_option('tests')
    depcppunit = dependency('cppunit', version: '>= 1.12')
endif

#################################################
# Optional dependencies and configuration
#################################################
progpod2man = find_program('pod2man', native: true, required: false)

conf = configuration_data()
conf.set_quoted('PACKAGE', 'jami')
conf.set_quoted('PACKAGE_NAME', 'Jami Daemon')
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('PACKAGE_STRING', 'Jami Daemon ' + meson.project_version())
conf.set_quoted('PROGSHAREDIR', get_option('datadir') / 'ring')

depopensl = meson.get_compiler('cpp').find_library('OpenSLES', has_headers: 'SLES/OpenSLES.h', required: get_option('opensl'))
conf.set10('HAVE_OPENSL', depopensl.found())

depalsa = dependency('alsa', version: '>= 1.0', required: get_option('alsa'))
conf.set10('HAVE_ALSA', depalsa.found())

deplibpulse = dependency('libpulse', version: '>= 0.9.15', required: get_option('pulseaudio'))
conf.set10('HAVE_PULSE', deplibpulse.found())

depjack = dependency('jack', required: get_option('jack'))
conf.set10('HAVE_JACK', depjack.found())

depportaudio = dependency('portaudio-2.0', required: get_option('portaudio'))
conf.set10('HAVE_PORTAUDIO', depportaudio.found())

deplibupnp = dependency('libupnp', required: get_option('upnp'))
conf.set10('HAVE_LIBUPNP', deplibupnp.found())

if get_option('natpmp_prefix') == ''
    depnatpmp = meson.get_compiler('cpp').find_library('natpmp', has_headers: 'natpmp.h', required: get_option('natpmp'))
else
    depnatpmp_ = meson.get_compiler('cpp').find_library('natpmp', dirs: get_option('natpmp_prefix') / 'lib', required: get_option('natpmp'))
    if depnatpmp_.found()
        depnatpmp = declare_dependency(
            compile_args: '-I' + get_option('natpmp_prefix') / 'include',
            dependencies: depnatpmp_
        )
    else
        depnatpmp = depnatpmp_
    endif
endif
conf.set10('HAVE_LIBNATPMP', depnatpmp.found())

depopenssl = dependency('openssl', required: get_option('name_service'))
conf.set10('HAVE_RINGNS', depopenssl.found())

if get_option('video')
    conf.set('ENABLE_VIDEO', true)
    if host_machine.system() == 'linux' and meson.get_compiler('cpp').get_define('__ANDROID__') != '1'
        deplibudev = dependency('libudev')
    endif

    if get_option('hw_acceleration')
        conf.set('RING_ACCEL', true)
        conf.set('ENABLE_VIDEOTOOLBOX', host_machine.system() == 'darwin')
116 117 118
    else
        conf.set('RING_ACCEL', false)
        conf.set('ENABLE_VIDEOTOOLBOX', false)
119
    endif
120 121 122 123
else
    conf.set('ENABLE_VIDEO', false)
    conf.set('RING_ACCEL', false)
    conf.set('ENABLE_VIDEOTOOLBOX', false)
124 125
endif

126 127 128 129 130 131 132 133 134 135 136 137 138 139
if get_option('plugins')
    conf.set('ENABLE_PLUGIN', true)
    deplibarchive = dependency('libarchive', version: '>= 3.4.0', required: false)
    if not deplibarchive.found()
        deplibarchive = modcmake.subproject('libarchive', cmake_options: [
            '-DCMAKE_BUILD_TYPE=Release',
            '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
            '-DENABLE_TEST=OFF',
            '-DENABLE_TAR=OFF',
            '-DENABLE_CPIO=OFF',
            '-DENABLE_CAT=OFF',
            '-DENABLE_LIBXML2=OFF'
        ]).dependency('archive_static')
    endif
Vladimir Stoiakin's avatar
Vladimir Stoiakin committed
140
    depdl = meson.get_compiler('cpp').find_library('dl', required: false)
141 142 143 144
else
    conf.set('ENABLE_PLUGIN', false)
endif

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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
conf.set10('HAVE_COREAUDIO', host_machine.system() == 'darwin')
conf.set10('HAVE_SHM', host_machine.system() == 'linux' and meson.get_compiler('cpp').get_define('__ANDROID__') != '1')

configure_file(
    output: 'config.h',
    configuration: conf
)
add_project_arguments('-DHAVE_CONFIG_H', language: 'cpp')
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')

#################################################
# Build targets
#################################################
add_project_arguments('-DRING_BUILD', language: 'cpp')
add_project_arguments('-DRING_BUILD', language: 'c')
if get_option('default_library') != 'static'
    add_project_arguments('-Ddring_EXPORTS', language: 'cpp')
    add_project_arguments('-Ddring_EXPORTS', language: 'c')
endif

add_project_arguments('-DASIO_STANDALONE', language: 'cpp')
add_project_arguments('-DASIO_STANDALONE', language: 'c')

subdir('src')

if get_option('interfaces').contains('dbus')
    subdir('bin' / 'dbus')
endif

if get_option('interfaces').contains('nodejs')
    subdir('bin' / 'nodejs')
endif

if get_option('tests')
    subdir('test')
endif

#################################################
# Resources and metafiles
#################################################
subdir('ringtones')

if host_machine.system() == 'linux' and meson.get_compiler('cpp').get_define('__ANDROID__') != '1'
    provides_content = ''
    if get_option('interfaces').contains('dbus')
        provides_content += '  <dbus type="user">cx.ring.Ring</dbus>'
    endif
    if get_option('interfaces').contains('library')
        provides_content += (provides_content == '')? '' : '\n'
        if get_option('default_library') == 'static'
            provides_content += '  <library>libjami.a</library>'
        elif get_option('default_library') == 'shared'
            provides_content += '  <library>libjami.so</library>'
        else
            provides_content += '  <library>libjami.so</library>\n'
            provides_content += '  <library>libjami.a</library>'
        endif
    endif
    if provides_content != ''
        configure_file(
            configuration: {'PROVIDES_CONTENT': provides_content},
            input: 'net.jami.daemon.metainfo.xml.in',
            output: 'net.jami.daemon.metainfo.xml',
            install: true,
            install_dir: get_option('datadir') / 'metainfo'
        )
    endif
endif