Commit 7637ccfc authored by Frediano Ziglio's avatar Frediano Ziglio

build: Add Meson support

Allows to build the project with Meson.
All options from configure.ac were copied.
All targets are ported correctly with correct dependencies.
Tested distribution.
Tested CI build.
Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
Acked-by: default avatarEduardo Lima (Etrunko) <etrunko@redhat.com>
parent 79a497c0
public_headers = [
'display-info.hpp',
'error.hpp',
'frame-capture.hpp',
'plugin.hpp',
'x11-display-info.hpp',
]
install_headers(public_headers,
subdir : 'spice-streaming-agent')
#
# project definition
#
project('spice-streaming-agent', 'c', 'cpp',
version : '0.3',
license : 'LGPLv2.1',
meson_version : '>= 0.49',
default_options : [
'buildtype=debugoptimized',
'warning_level=2',
'cpp_std=c++11',
])
#
# check for dependencies
#
spice_protocol_version='0.12.16'
#
# global defines
#
include_dirs = [include_directories('include', '.')]
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
plugins_dir_relative = get_option('libdir') / meson.project_name() / 'plugins'
global_cflags = [
'-Wno-unused-parameter'
]
add_project_arguments(cc.get_supported_arguments(global_cflags), language : 'c')
add_project_arguments(cxx.get_supported_arguments(global_cflags), language : 'cpp')
global_link_args = [
'-Wl,-z,relro',
'-Wl,-z,now',
'-Wl,--no-copy-dt-needed-entries',
]
global_link_args = cxx.get_supported_link_arguments(global_link_args)
#
# set up subprojects
#
spice_common = subproject('spice-common', default_options : ['generate-code=all'])
spice_common_deps = [spice_common.get_variable('spice_common_client_dep')]
#
# check for options
#
config_data = configuration_data()
compile_gst_plugin = false
gst_deps = []
if not get_option('gst-plugin').disabled()
deps = ['gstreamer-1.0', 'gstreamer-app-1.0']
foreach dep : deps
gst_deps += dependency(dep, version: '>= 1.10', required : get_option('gst-plugin'))
endforeach
compile_gst_plugin = true
endif
compile_tests = false
if not get_option('unittests').disabled()
has_catch = false
if not has_catch and cxx.has_header('catch/catch.hpp')
config_data.set('HAVE_CATCH_CATCH_HPP', '1')
has_catch = true
endif
if not has_catch and cxx.has_header('catch2/catch.hpp')
config_data.set('HAVE_CATCH2_CATCH_HPP', '1')
has_catch = true
endif
if not has_catch and get_option('unittests').enabled()
error('Could not find Catch dependency header (catch.hpp)')
endif
compile_tests = has_catch
endif
#
# subdirectories
#
subdir('include/spice-streaming-agent')
subdir('src')
#
# write config.h
#
configure_file(output : 'config.h',
configuration : config_data)
#
# write:
# - spice-streaming-agent.pc
# - spice-streaming-agent.spec
# - spice-streaming.desktop
#
config_data = configuration_data()
config_data.set('PACKAGE', meson.project_name())
config_data.set('VERSION', meson.project_version())
config_data.set('SPICE_PROTOCOL_MIN_VER', spice_protocol_version)
config_data.set('BINDIR', get_option('prefix') / get_option('bindir'))
pkgconfig = import('pkgconfig')
plugins_dir = '${exec_prefix}' / plugins_dir_relative
pkgconfig.generate(name: meson.project_name(),
description : 'SPICE streaming agent headers',
version : meson.project_version(),
requires : 'spice-protocol >= @0@'.format(spice_protocol_version),
variables : [
'exec_prefix=${prefix}',
'plugindir=@0@'.format(plugins_dir),
])
configure_file(input : 'spice-streaming-agent.spec.in',
output : 'spice-streaming-agent.spec',
configuration : config_data)
# this will start the program for the login session
desktop = configure_file(input : 'data/spice-streaming.desktop.in',
output : 'spice-streaming.desktop',
install_dir : get_option('datadir') / 'gdm/greeter/autostart',
configuration : config_data)
# this will start the program for each user session
install_data(desktop,
install_dir : get_option('sysconfdir') / 'xdg/autostart')
install_man('spice-streaming-agent.1')
#
# instal 90-spice-guest-streaming.rules
#
udevrulesdir = get_option('udevrulesdir')
if udevrulesdir == ''
udevrulesdir = get_option('prefix') / 'lib/udev/rules.d'
endif
install_data('data/90-spice-guest-streaming.rules',
install_dir : udevrulesdir)
option('gst-plugin',
type : 'feature',
description : 'Enable GStreamer based plugin')
option('unittests',
type : 'feature',
description : 'Enable tests (they require \'catch\' to be installed)')
option('udevrulesdir',
type : 'string',
description : 'udev rules.d directory')
#
# \copyright
# Copyright 2016-2017 Red Hat Inc. All rights reserved.
#
plugins_dir = get_option('prefix') / plugins_dir_relative
utils_sources = [
'hexdump.c',
'hexdump.h',
]
utils_lib = static_library('streaming-utils', utils_sources,
install : false,
include_directories : include_dirs)
agent_sources = [
'spice-streaming-agent.cpp',
'concrete-agent.cpp',
'concrete-agent.hpp',
'cursor-updater.cpp',
'cursor-updater.hpp',
'display-info.cpp',
'frame-log.cpp',
'frame-log.hpp',
'mjpeg-fallback.cpp',
'mjpeg-fallback.hpp',
'jpeg.cpp',
'jpeg.hpp',
'stream-port.cpp',
'stream-port.hpp',
'utils.cpp',
'utils.hpp',
'x11-display-info.cpp',
]
agent_cpp_args = [
'-DSPICE_STREAMING_AGENT_PROGRAM',
'-DPLUGINSDIR="@0@"'.format(plugins_dir),
]
agent_link_args = global_link_args
agent_deps = spice_common_deps
foreach dep : ['libjpeg', 'libdrm', 'x11', 'xfixes', 'xrandr']
agent_deps += dependency(dep)
endforeach
agent_deps += cc.find_library('dl', required : false)
executable('spice-streaming-agent', agent_sources,
cpp_args : agent_cpp_args,
include_directories : include_dirs,
install : true,
link_args : agent_link_args,
export_dynamic : true,
link_with : utils_lib,
dependencies : [agent_deps],
gnu_symbol_visibility : 'inlineshidden',
pie : true)
if compile_gst_plugin
gst_plugin_sources = [
'gst-plugin.cpp',
]
gst_plugin_cpp_args = []
gst_plugin_link_args = global_link_args
gst_plugin_deps = spice_common_deps + gst_deps
shared_module('gst-plugin', gst_plugin_sources,
name_prefix : '',
cpp_args : gst_plugin_cpp_args,
include_directories : include_dirs,
install : true,
install_dir : plugins_dir,
link_args : gst_plugin_link_args,
dependencies : [gst_plugin_deps],
gnu_symbol_visibility : 'inlineshidden')
endif
if compile_tests
subdir('unittests')
endif
test_include_dirs = include_dirs + [include_directories('..', '.')]
tests = [
{
'name' : 'hexdump',
'is_test' : false,
'sources' : 'hexdump.c',
'link_with' : utils_lib,
},
{
'name' : 'test-mjpeg-fallback',
'sources' : [
'test-mjpeg-fallback.cpp',
'../display-info.cpp',
'../jpeg.cpp',
'../mjpeg-fallback.cpp',
'../utils.cpp',
'../x11-display-info.cpp',
'spice-catch.hpp',
],
'dependencies' : agent_deps,
},
{
'name' : 'test-stream-port',
'sources' : [
'test-stream-port.cpp',
'../stream-port.cpp',
'spice-catch.hpp',
],
'dependencies' : spice_common_deps,
}
]
foreach t : tests
test_name = t.get('name')
is_test = t.get('is_test', true)
exe = executable(test_name,
sources : t.get('sources'),
include_directories : test_include_dirs,
link_with : t.get('link_with', []),
dependencies : t.get('dependencies', []),
install : false,
gnu_symbol_visibility : 'inlineshidden')
if is_test
test(test_name, exe)
endif
endforeach
# test-hexdump.sh as test
test('test-hexdump',
find_program('test-hexdump.sh'),
workdir : meson.current_build_dir())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment