1 project('gobject-introspection', 'c',
3 meson_version: '>= 0.49.2',
6 'buildtype=debugoptimized',
10 host_system = host_machine.system()
11 gi_versions = meson.project_version().split('.')
13 configinc = include_directories('.')
15 pymod = import('python')
16 python = pymod.find_installation(get_option('python'))
18 python_version = python.language_version()
19 python_version_req = '>=3.4'
20 if not python_version.version_compare(python_version_req)
21 error('Requires Python @0@, @1@ found.'.format(python_version_req, python_version))
24 cc = meson.get_compiler('c')
27 if cc.get_id() != 'msvc'
32 '-Wdeclaration-after-statement',
33 '-Wduplicated-branches',
36 '-Wformat-nonliteral',
38 '-Wimplicit-function-declaration',
42 '-Wmissing-declarations',
43 '-Wmissing-format-attribute',
44 '-Wmissing-include-dirs',
46 '-Wmissing-prototypes',
49 '-Wold-style-definition',
57 '-Wstrict-prototypes',
59 '-Wunused-but-set-variable',
64 '-fno-strict-aliasing',
68 '-FImsvc_recommended_pragmas.h',
72 project_c_args = cc.get_supported_arguments(project_c_args)
73 add_project_arguments(project_c_args, language: 'c')
75 config = configuration_data()
77 config.set('GI_MAJOR_VERSION', gi_versions[0])
78 config.set('GI_MINOR_VERSION', gi_versions[1])
79 config.set('GI_MICRO_VERSION', gi_versions[2])
81 config.set_quoted('GIR_SUFFIX', 'gir-1.0')
82 gir_dir_prefix = get_option('gir_dir_prefix')
83 if gir_dir_prefix == ''
84 gir_dir_prefix = join_paths(get_option('prefix'), get_option('datadir'))
85 gir_dir_pc_prefix = '${datadir}'
87 gir_dir_prefix = join_paths(get_option('prefix'), gir_dir_prefix)
88 gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix)
90 girdir = join_paths(gir_dir_prefix, 'gir-1.0')
91 config.set_quoted('GIR_DIR', girdir)
92 config.set_quoted('GOBJECT_INTROSPECTION_LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
93 config.set_quoted('UNINSTALLED_GIR_DIR', join_paths(meson.current_build_dir(), 'gir'))
95 foreach type : ['char', 'short', 'int', 'long']
96 size = cc.sizeof(type)
98 error('Failed to get size of @0@'.format(type))
100 config.set('SIZEOF_@0@'.format(type.to_upper()), size)
103 add_project_arguments(['-DHAVE_CONFIG_H'], language: 'c')
105 gi_hidden_visibility_cflags = []
106 if host_system == 'windows'
107 config.set('DLL_EXPORT', true)
108 config.set('_GI_EXTERN', '__declspec(dllexport) extern')
109 if cc.get_id() != 'msvc'
110 gi_hidden_visibility_cflags += '-fvisibility=hidden'
113 config.set('_GI_EXTERN', '__attribute__((visibility("default"))) extern')
114 gi_hidden_visibility_cflags += '-fvisibility=hidden'
118 configuration: config,
122 # FIXME: Always bumped to match our version
123 #glib_version = '>=2.@0@.@1@'.format(gi_versions[1], gi_versions[2])
124 glib_version = '>= 2.58.0'
126 glib_dep = dependency('glib-2.0', version : glib_version,
127 fallback: ['glib', 'libglib_dep'])
128 gobject_dep = dependency('gobject-2.0', version : glib_version,
129 fallback: ['glib', 'libgobject_dep'])
130 gio_dep = dependency('gio-2.0', version : glib_version,
131 fallback: ['glib', 'libgio_dep'])
132 gmodule_dep = dependency('gmodule-2.0', version : glib_version,
133 fallback: ['glib', 'libgmodule_dep'])
134 if host_system != 'windows'
135 giounix_dep = dependency('gio-unix-2.0', version : glib_version,
136 fallback: ['glib', 'libgiounix_dep'])
138 # Don't even try to look for gio-unix-2.0 on Windows because Meson will
139 # fruitlessly try to find it in the glib subproject even when we don't want
140 # it to look in the subproject at all. Just use a not-found dependency.
141 giounix_dep = dependency('', required : false)
142 # XXX: Autotools doesn't build girs for gio-win32-2.0, but maybe we should?
144 libffi_dep = dependency('libffi',
145 fallback : ['libffi', 'ffi_dep'])
147 with_cairo = get_option('cairo')
150 cairo_dep = dependency('cairo', required: cc.get_id() != 'msvc')
151 cairo_gobject_dep = dependency('cairo-gobject', required: cc.get_id() != 'msvc')
153 if cc.get_id() == 'msvc' and (not cairo_gobject_dep.found() or not cairo_dep.found())
154 if cc.has_header('cairo.h') and cc.has_header ('cairo-gobject.h')
155 cairo_dep = cc.find_library ('cairo')
156 cairo_gobject_dep = cc.find_library ('cairo-gobject')
160 warning('Not building with cairo support, not all tests will be run')
163 with_doctool = get_option('doctool')
165 warning('Not building with doctool support, not all tests will be run')
168 subdir('girepository')
176 install_data('Makefile.introspection', install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0'))
177 install_data('m4/introspection.m4', install_dir: join_paths(get_option('datadir'), 'aclocal'))
179 prefix = get_option('prefix')
180 pkgconfig_conf = configuration_data()
181 pkgconfig_conf.set('prefix', prefix)
182 pkgconfig_conf.set('exec_prefix', '${prefix}')
183 pkgconfig_conf.set('bindir', join_paths('${exec_prefix}', get_option('bindir')))
184 pkgconfig_conf.set('libdir', join_paths('${exec_prefix}', get_option('libdir')))
185 pkgconfig_conf.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
186 pkgconfig_conf.set('datadir', '${datarootdir}')
187 pkgconfig_conf.set('includedir', join_paths('${prefix}', get_option('includedir')))
188 pkgconfig_conf.set('GIR_PC_DIR', join_paths(gir_dir_pc_prefix, 'gir-1.0'))
189 if host_system == 'windows' or host_system == 'cygwin'
190 pkgconfig_conf.set('EXEEXT', '.exe')
192 pkgconfig_conf.set('EXEEXT', '')
194 pkgconfig_conf.set('VERSION', meson.project_version())
195 pkgconfig_conf.set('FFI_PC_PACKAGES', 'libffi')
196 if libffi_dep.type_name() == 'pkgconfig'
197 prog_pkgconfig = find_program('pkg-config')
198 pkgconfig_conf.set('FFI_PC_CFLAGS', run_command(prog_pkgconfig, ['libffi', '--cflags-only-I']).stdout())
199 pkgconfig_conf.set('FFI_PC_LIBS', run_command(prog_pkgconfig, ['libffi', '--libs-only-l']).stdout())
201 # XXX: We can't know the correct values for these, needs meson API. Maybe we
202 # should use meson's pkgconfig module to generate the whole file.
203 pkgconfig_conf.set('FFI_PC_CFLAGS', '')
204 pkgconfig_conf.set('FFI_PC_LIBS', '-lffi')
208 input: 'gobject-introspection-no-export-1.0.pc.in',
209 output: 'gobject-introspection-no-export-1.0.pc',
210 configuration: pkgconfig_conf,
211 install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
215 input: 'gobject-introspection-1.0.pc.in',
216 output: 'gobject-introspection-1.0.pc',
217 configuration: pkgconfig_conf,
218 install_dir: join_paths(get_option('libdir'), 'pkgconfig'),