usbredir
/
meson.build
117 строк · 2.7 Кб
1project('usbredir', 'c',
2version: '0.15.0',
3license: 'LGPLv2.1+',
4meson_version : '>= 0.53',
5default_options : [
6'buildtype=debugoptimized',
7'warning_level=1',
8])
9
10summary_info = {'prefix': get_option('prefix')}
11
12usbredir_include_root_dir = include_directories('.')
13
14cc_flags = [
15'--param=ssp-buffer-size=4',
16]
17if host_machine.system() != 'windows'
18cc_flags += [ '-D_FORTIFY_SOURCE=2' ]
19if not get_option('stack_protector').disabled()
20cc_flags += [ '-fstack-protector' ]
21endif
22endif
23
24# Check if we are building from .git
25git = run_command('test', '-d', '.git', check : false).returncode() == 0
26git_werror = get_option('git_werror')
27if git_werror.enabled() or git_werror.auto() and git
28cc_flags += [ '-Werror' ]
29endif
30
31compiler = meson.get_compiler('c')
32supported_cc_flags = compiler.get_supported_arguments(cc_flags)
33add_project_arguments(supported_cc_flags, language: 'c')
34
35config = configuration_data()
36
37if get_option('extra-checks')
38config.set('ENABLE_EXTRA_CHECKS', '1')
39endif
40
41config.set('USBREDIR_VISIBLE', '')
42foreach visibility : [
43'__attribute__((visibility ("default")))',
44'__attribute__((dllexport))',
45'__declspec(dllexport)',
46]
47code = '@0@ int func() { return 123; }'.format(visibility)
48if compiler.compiles(code, name : 'visibility check')
49config.set('USBREDIR_VISIBLE', visibility)
50break
51endif
52endforeach
53
54#
55# write config.h
56#
57proj_name = meson.project_name()
58proj_version = meson.project_version()
59config_data = {
60'VERSION' : proj_version,
61'PACKAGE_VERSION' : proj_version,
62'PACKAGE_STRING' : '@0@ @1@'.format(proj_name, proj_version),
63'PACKAGE_BUGREPORT' : 'https://gitlab.freedesktop.org/spice/usbredir/issues',
64}
65
66foreach key, value : config_data
67config.set_quoted(key, value)
68endforeach
69
70#
71# check for system headers
72#
73headers = [
74'inttypes.h',
75'stdint.h',
76'stdlib.h',
77'strings.h',
78'string.h',
79'sys/stat.h',
80'sys/types.h',
81'unistd.h',
82]
83
84foreach header : headers
85if compiler.has_header(header)
86config.set('HAVE_@0@'.format(header.underscorify().to_upper()), '1')
87endif
88endforeach
89
90if host_machine.system() == 'windows'
91wixl_arch = 'x64'
92if host_machine.cpu() != 'x86_64'
93wixl_arch = 'x86'
94endif
95config.set('WIXL_ARCH', wixl_arch)
96endif
97
98configure_file(output : 'config.h', configuration : config)
99
100subdir('usbredirparser')
101subdir('usbredirhost')
102if get_option('tools').enabled()
103subdir('tools')
104endif
105if host_machine.system() != 'windows'
106subdir('usbredirtestclient')
107
108if get_option('fuzzing').enabled()
109subdir('fuzzing')
110endif
111endif
112if get_option('tests').enabled()
113subdir('tests')
114endif
115subdir('data')
116
117summary(summary_info, bool_yn: true)
118