Imported Upstream version 2.56.0
[platform/upstream/glib.git] / glib / meson.build
1 configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
2   install : true,
3   install_dir : join_paths(get_option('libdir'), 'glib-2.0/include'),
4   configuration : glibconfig_conf)
5
6 subdir('libcharset')
7 if not use_system_pcre
8   subdir('pcre')
9 endif
10 if have_good_vsnprintf and have_good_snprintf
11   gnulib_lib = []
12 else
13   subdir('gnulib')
14 endif
15
16 glib_headers = files(
17   'glib.h',
18   'glib-unix.h',
19   'glib-object.h',
20 )
21 install_headers(glib_headers, subdir : 'glib-2.0')
22
23 glib_deprecated_headers = files(
24   'deprecated/gallocator.h',
25   'deprecated/gcache.h',
26   'deprecated/gcompletion.h',
27   'deprecated/gmain.h',
28   'deprecated/grel.h',
29   'deprecated/gthread.h',
30 )
31 install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')
32
33 glib_sub_headers = files(
34   'glib-autocleanups.h',
35   'galloca.h',
36   'garray.h',
37   'gasyncqueue.h',
38   'gatomic.h',
39   'gbacktrace.h',
40   'gbase64.h',
41   'gbitlock.h',
42   'gbookmarkfile.h',
43   'gbytes.h',
44   'gcharset.h',
45   'gchecksum.h',
46   'gconvert.h',
47   'gdataset.h',
48   'gdate.h',
49   'gdatetime.h',
50   'gdir.h',
51   'genviron.h',
52   'gerror.h',
53   'gfileutils.h',
54   'ggettext.h',
55   'ghash.h',
56   'ghmac.h',
57   'ghook.h',
58   'ghostutils.h',
59   'gi18n.h',
60   'gi18n-lib.h',
61   'giochannel.h',
62   'gkeyfile.h',
63   'glist.h',
64   'gmacros.h',
65   'gmain.h',
66   'gmappedfile.h',
67   'gmarkup.h',
68   'gmem.h',
69   'gmessages.h',
70   'gnode.h',
71   'goption.h',
72   'gpattern.h',
73   'gpoll.h',
74   'gprimes.h',
75   'gqsort.h',
76   'gquark.h',
77   'gqueue.h',
78   'grand.h',
79   'gregex.h',
80   'gscanner.h',
81   'gsequence.h',
82   'gshell.h',
83   'gslice.h',
84   'gslist.h',
85   'gspawn.h',
86   'gstdio.h',
87   'gstrfuncs.h',
88   'gtestutils.h',
89   'gstring.h',
90   'gstringchunk.h',
91   'gthread.h',
92   'gthreadpool.h',
93   'gtimer.h',
94   'gtimezone.h',
95   'gtrashstack.h',
96   'gtree.h',
97   'gtypes.h',
98   'guuid.h',
99   'gunicode.h',
100   'gurifuncs.h',
101   'gutils.h',
102   'gvarianttype.h',
103   'gvariant.h',
104   'gversion.h',
105   'gversionmacros.h',
106   'gwin32.h',
107   'gprintf.h',
108 )
109 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
110
111 deprecated_sources = files(
112   'deprecated/gallocator.c',
113   'deprecated/gcache.c',
114   'deprecated/gcompletion.c',
115   'deprecated/grel.c',
116   'deprecated/gthread-deprecated.c'
117 )
118
119 glib_sources = files(
120   'garray.c',
121   'gasyncqueue.c',
122   'gatomic.c',
123   'gbacktrace.c',
124   'gbase64.c',
125   'gbitlock.c',
126   'gbookmarkfile.c',
127   'gbytes.c',
128   'gcharset.c',
129   'gchecksum.c',
130   'gconvert.c',
131   'gdataset.c',
132   'gdate.c',
133   'gdatetime.c',
134   'gdir.c',
135   'genviron.c',
136   'gerror.c',
137   'gfileutils.c',
138   'ggettext.c',
139   'ghash.c',
140   'ghmac.c',
141   'ghook.c',
142   'ghostutils.c',
143   'giochannel.c',
144   'gkeyfile.c',
145   'glib-init.c',
146   'glib-private.c',
147   'glist.c',
148   'gmain.c',
149   'gmappedfile.c',
150   'gmarkup.c',
151   'gmem.c',
152   'gmessages.c',
153   'gnode.c',
154   'goption.c',
155   'gpattern.c',
156   'gpoll.c',
157   'gprimes.c',
158   'gqsort.c',
159   'gquark.c',
160   'gqueue.c',
161   'grand.c',
162   'gregex.c',
163   'gscanner.c',
164   'gsequence.c',
165   'gshell.c',
166   'gslice.c',
167   'gslist.c',
168   'gstdio.c',
169   'gstrfuncs.c',
170   'gstring.c',
171   'gstringchunk.c',
172   'gtestutils.c',
173   'gthread.c',
174   'gthreadpool.c',
175   'gtimer.c',
176   'gtimezone.c',
177   'gtranslit.c',
178   'gtrashstack.c',
179   'gtree.c',
180   'guniprop.c',
181   'gutf8.c',
182   'gunibreak.c',
183   'gunicollate.c',
184   'gunidecomp.c',
185   'gurifuncs.c',
186   'gutils.c',
187   'guuid.c',
188   'gvariant.c',
189   'gvariant-core.c',
190   'gvariant-parser.c',
191   'gvariant-serialiser.c',
192   'gvarianttypeinfo.c',
193   'gvarianttype.c',
194   'gversion.c',
195   'gwakeup.c',
196   'gprintf.c',
197 )
198
199 if host_system == 'windows'
200   glib_win_rc = configure_file(
201     input: 'glib.rc.in',
202     output: 'glib.rc',
203     configuration: glibconfig_conf,
204   )
205   glib_win_res = windows.compile_resources(glib_win_rc)
206   glib_sources += [glib_win_res]
207   glib_sources += files('gthread-win32.c')
208   glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
209   platform_deps = [winsock2, cc.find_library('winmm')]
210 else
211   glib_sources += files('gthread-posix.c')
212   glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
213   platform_deps = []
214 endif
215
216 if enable_dtrace
217   glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
218   glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
219 else
220   glib_dtrace_obj = []
221   glib_dtrace_hdr = []
222 endif
223
224 pcre_static_args = []
225
226 if use_pcre_static_flag
227   pcre_static_args = ['-DPCRE_STATIC']
228 endif
229
230 libglib = library('glib-2.0',
231   glib_dtrace_obj, glib_dtrace_hdr,
232   sources : [deprecated_sources, glib_sources],
233   version : library_version,
234   soversion : soversion,
235   install : true,
236   # intl.lib is not compatible with SAFESEH
237   link_args : platform_ldflags + noseh_link_args,
238   include_directories : configinc,
239   link_with : [charset_lib, gnulib_lib],
240   dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps,
241   c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
242 )
243
244 libglib_dep = declare_dependency(
245   link_with : libglib,
246   # thread_dep doesn't get pulled in from libglib atm,
247   # see https://github.com/mesonbuild/meson/issues/1426
248   dependencies : [thread_dep],
249   # We sadly need to export configinc here because everyone includes <glib/*.h>
250   include_directories : [configinc, glibinc])
251
252 # On Windows, glib needs a spawn helper for g_spawn* API
253 if host_system == 'windows'
254   if host_machine.cpu_family() == 'x86'
255     executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
256       install : true,
257       gui_app : true,
258       include_directories : configinc,
259       dependencies : [libintl, libglib_dep])
260     executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
261       install : true,
262       c_args : ['-DHELPER_CONSOLE'],
263       include_directories : configinc,
264       dependencies : [libintl, libglib_dep])
265   else
266     executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
267       install : true,
268       gui_app : true,
269       include_directories : configinc,
270       dependencies : [libintl, libglib_dep])
271     executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
272       install : true,
273       c_args : ['-DHELPER_CONSOLE'],
274       include_directories : configinc,
275       dependencies : [libintl, libglib_dep])
276   endif
277 else
278   gtester = executable('gtester', 'gtester.c',
279     install : true,
280     include_directories : configinc,
281     dependencies : [libglib_dep])
282 endif
283
284 install_data('gtester-report', install_dir : get_option('bindir'))
285
286 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
287
288 gdb_conf = configuration_data()
289 gdb_conf.set('datadir', glib_datadir)
290 # This is also used in gobject/meson.build
291 if host_system != 'windows'
292   # XXX: We add a leading './' because glib_libdir is an absolute path and we
293   # need it to be a relative path so that join_paths appends it to the end.
294   gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
295 else
296   # FIXME: Cannot install on Windows because the path will contain a drive
297   # letter and colons are not allowed in paths.
298   gdb_install_dir = false
299 endif
300 configure_file(
301   input: 'libglib-gdb.py.in',
302   output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
303   configuration: gdb_conf,
304   install_dir: gdb_install_dir,
305 )
306
307 if enable_systemtap
308   glib_stp = configure_file(input : 'glib.stp.in',
309     output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
310     configuration : stp_cdata,
311     install_dir : tapset_install_dir,
312     install : true)
313 endif
314
315 # gtester doesn't work on native windows
316 if cc.get_id() != 'msvc'
317   subdir('tests')
318 endif