Debian Codegraph @

meson.build

raw
1 # https://gitlab.gnome.org/GNOME/gnome-system-monitor/issues
2 project('gnome-system-monitor',
3 'c', 'cpp',
4 default_options : [
5 'c_std=gnu2x',
6 'cpp_std=gnu++20',
7 'warning_level=3',
8 'b_lto=true',
9 ],
10 version: '51.beta',
11 meson_version: '>=0.57.0',
12 )
13
14
15 gnome = import('gnome')
16 i18n = import('i18n')
17
18 cc = meson.get_compiler('c')
19 cx = meson.get_compiler('cpp')
20
21 if get_option('development')
22 app_id = 'org.gnome.SystemMonitor.Devel'
23 else
24 app_id = 'org.gnome.SystemMonitor'
25 endif
26
27 gettext_package = meson.project_name()
28
29 conf = configuration_data()
30 conf.set_quoted('APP_ID', app_id)
31 conf.set_quoted('VERSION', meson.project_version())
32 conf.set_quoted('GETTEXT_PACKAGE', gettext_package)
33 conf.set_quoted('GNOMELOCALEDIR',
34 join_paths(get_option('prefix'), get_option('localedir'))
35 )
36 conf.set_quoted('GSM_LIBEXEC_DIR',
37 join_paths(get_option('prefix'), get_option('libexecdir'), meson.project_name())
38 )
39
40 dataconf = configuration_data()
41 dataconf.set('APP_ID', app_id)
42 dataconf.set('VERSION', meson.project_version())
43 dataconf.set('GETTEXT_PACKAGE', gettext_package)
44 dataconf.set('bindir', join_paths(get_option('prefix'),get_option('bindir')))
45 dataconf.set('pkglibexecdir',
46 join_paths(get_option('prefix'),get_option('libexecdir'),meson.project_name())
47 )
48
49 prefix = get_option('prefix')
50 datadir = join_paths(prefix, get_option('datadir'))
51
52
53 ################################################################################
54 # Dependencies
55
56 giomm = dependency('giomm-2.68', version: '>=2.80')
57 glib = dependency('glib-2.0', version: '>=2.80')
58 gio_unix = dependency('gio-unix-2.0', version: '>=2.84')
59 glibmm = dependency('glibmm-2.68', version: '>=2.68')
60 gmodule = dependency('gmodule-2.0')
61 gtk = dependency('gtk4', version: '>=4.17.5')
62 gtkmm = dependency('gtkmm-4.0', version: '>=4.17.5')
63 libgtop = dependency('libgtop-2.0', version: '>=2.41.2')
64 libadwaita = dependency('libadwaita-1',version: '>=1.8.alpha')
65 librsvg = dependency('librsvg-2.0', version: '>=2.46')
66
67 if get_option('systemd')
68 libsystemd = dependency('libsystemd', version: '>=44')
69 conf.set('HAVE_SYSTEMD', libsystemd.found())
70 else
71 libsystemd = dependency('', required: false)
72 conf.set('HAVE_SYSTEMD', false)
73 endif
74
75
76 ################################################################################
77 # Compiler flags
78
79 extra_flags = [
80 '-Wcast-align',
81 '-Wchar-subscripts',
82 '-Winline',
83 '-Wmissing-declarations',
84 '-Wpointer-arith',
85 '-Wsign-compare',
86 '-Werror=odr',
87 '-Werror=lto-type-mismatch',
88 '-Werror=strict-aliasing',
89 ]
90 extra_cflags = [
91 '-Wmissing-prototypes',
92 '-Wnested-externs',
93 '-Wno-pedantic',
94 ]
95 extra_cxxflags = [
96 # '-fvisibility=hidden',
97 # '-fvisibility-inlines-hidden',
98 ]
99
100
101 cflags = extra_flags + extra_cflags
102 cxxflags = extra_flags + extra_cxxflags
103
104 add_project_arguments(cc.get_supported_arguments(cflags),
105 language: 'c'
106 )
107 add_project_arguments(cx.get_supported_arguments(cxxflags),
108 language: 'cpp'
109 )
110
111 conf.set('HAVE_LKSTRFTIME', cc.has_function('strftime'))
112 has_sysmacros = cc.has_header_symbol('sys/sysmacros.h', 'major')
113 conf.set('HAVE_DEV_IN_SYSMACROS', has_sysmacros)
114 conf.set('HAVE_DEV_IN_TYPES', cc.has_header_symbol('sys/types.h', 'major', required: not has_sysmacros))
115
116 config_h = configure_file(
117 output: 'config.h',
118 configuration: conf,
119 )
120
121
122 ################################################################################
123 # Tests
124
125 python3 = find_program('python3', required: false)
126 git = find_program('git', required: false)
127 patch = find_program('patch', required: false)
128 uncrustify = find_program('uncrustify', required: false)
129
130 check_style_file = files('check-style.py')
131 check_style_prog = find_program(check_style_file)
132
133 if python3.found() and git.found() and patch.found() and uncrustify.found()
134 test('code formatting',
135 check_style_prog,
136 args: ['--all', '--dry-run'],
137 suite: 'formatting',
138 )
139 else
140 message('Code formatting test requires: python3, git, patch, uncrustify')
141 endif
142
143
144 ################################################################################
145 # Subdirectories
146
147 rootInclude = include_directories('.')
148
149 subdir('data')
150 subdir('po')
151 subdir('scripts')
152 subdir('src')
153 subdir('help')
154
155
156 message('\n'.join(['',
157 'Configuration:',
158 '',
159 ' Source code location: @0@'.format(meson.project_source_root()),
160 ' C Compiler: @0@ @1@'.format(cc.get_id(), cc.version()),
161 ' C++ Compiler: @0@ @1@'.format(cx.get_id(), cx.version()),
162 ' CFLAGS: @0@'.format(cflags),
163 ' CXXFLAGS: @0@'.format(cxxflags),
164 ' systemd support: @0@'.format(libsystemd.found()),
165 ]))
166
167
168 # Extra scripts
169 gnome.post_install(
170 glib_compile_schemas: true,
171 gtk_update_icon_cache: true,
172 )