meson.build 5.07 KB
Newer Older
1
project('pygobject', 'c',
2
  version : '3.33.1',
3
  meson_version : '>= 0.46.0',
4 5 6 7 8 9 10 11 12 13 14 15
  default_options : [ 'warning_level=1',
                      'buildtype=debugoptimized'])

pygobject_version = meson.project_version()
version_arr = pygobject_version.split('.')
pygobject_version_major = version_arr[0].to_int()
pygobject_version_minor = version_arr[1].to_int()
pygobject_version_micro = version_arr[2].to_int()

platform_version = '@0@.0'.format(pygobject_version_major)

pymod = import('python')
16
python = pymod.find_installation(get_option('python'))
17

18
python_dep = python.dependency()
19

20
glib_version_req = '>= 2.48.0'
21 22 23 24
gi_version_req = '>= 1.46.0'
pycairo_version_req = '>= 1.11.1'
libffi_version_req = '>= 3.0'

25
gi_dep = dependency('gobject-introspection-1.0', version : gi_version_req,
26
  fallback: ['gobject-introspection', 'girepo_dep'])
27
glib_dep = dependency('glib-2.0', version : glib_version_req,
28
  fallback: ['glib', 'libglib_dep'])
29
gobject_dep = dependency('gobject-2.0', version : glib_version_req,
30
  fallback: ['glib', 'libgobject_dep'])
31
gio_dep = dependency('gio-2.0', version : glib_version_req,
32
  fallback: ['glib', 'libgio_dep'])
33
gmodule_dep = dependency('gmodule-2.0', version : glib_version_req,
34
  fallback: ['glib', 'libgmodule_dep'])
35
ffi_dep = dependency('libffi', version : '>= 3.0',
36 37
  fallback : ['libffi', 'ffi_dep'])

38
with_pycairo = get_option('pycairo')
39

40 41
cc = meson.get_compiler('c')

42
if with_pycairo
43 44 45 46 47 48 49 50 51
  cairo_dep = dependency('cairo', required: cc.get_id() != 'msvc')
  cairo_gobject_dep = dependency('cairo-gobject', required: cc.get_id() != 'msvc')

  if cc.get_id() == 'msvc' and (not cairo_gobject_dep.found() or not cairo_dep.found())
    if cc.has_header('cairo.h') and cc.has_header ('cairo-gobject.h')
      cairo_dep = cc.find_library ('cairo')
      cairo_gobject_dep = cc.find_library ('cairo-gobject')
    endif
  endif
52 53

  if python.language_version().version_compare('>= 3.0')
54
    pycairo_name = 'py3cairo'
55
  else
56
    pycairo_name = 'pycairo'
57
  endif
58 59 60 61 62 63 64

  pycairo_dep = dependency(
    pycairo_name,
    version: pycairo_version_req,
    fallback: ['pycairo', 'pycairo_dep'],
    default_options: ['python=' + get_option('python')],
  )
65 66
endif

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
main_c_args = []
if cc.get_id() == 'msvc'
  main_c_args += [ '-FImsvc_recommended_pragmas.h' ]
else
  main_c_args += [
    '-Wall',
    '-Warray-bounds',
    '-Wcast-align',
    '-Wduplicated-branches',
    '-Wextra',
    '-Wformat=2',
    '-Wformat-nonliteral',
    '-Wformat-security',
    '-Wimplicit-function-declaration',
    '-Winit-self',
    '-Wjump-misses-init',
    '-Wlogical-op',
    '-Wmissing-declarations',
    '-Wmissing-format-attribute',
    '-Wmissing-include-dirs',
    '-Wmissing-noreturn',
    '-Wmissing-prototypes',
    '-Wnested-externs',
    '-Wnull-dereference',
    '-Wold-style-definition',
    '-Wpacked',
    '-Wpointer-arith',
    '-Wrestrict',
    '-Wreturn-type',
    '-Wshadow',
    '-Wsign-compare',
    '-Wstrict-aliasing',
    '-Wstrict-prototypes',
100
    '-Wswitch-default',
101 102 103 104
    '-Wundef',
    '-Wunused-but-set-variable',
    '-Wwrite-strings',
  ]
105

106 107 108 109 110 111
  if python.language_version().split('.')[0] == '2'
    main_c_args += [
        '-Wdeclaration-after-statement',
    ]
  endif

112
  main_c_args += [
113 114 115 116 117 118 119
    '-Wno-incompatible-pointer-types-discards-qualifiers',
    '-Wno-missing-field-initializers',
    '-Wno-unused-parameter',
    '-Wno-discarded-qualifiers',
    '-Wno-sign-conversion',
    '-Wno-cast-function-type',
    '-Wno-int-conversion',
120 121
  ]

122 123 124 125 126 127 128
  main_c_args += [
    '-fno-strict-aliasing',
    '-fvisibility=hidden',
  ]

  main_c_args = cc.get_supported_arguments(main_c_args)
endif
129

130 131
pyext_c_args = ['-DPY_SSIZE_T_CLEAN']

132 133 134 135 136 137 138 139 140 141 142 143
cdata = configuration_data()

cdata.set('PYGOBJECT_MAJOR_VERSION', pygobject_version_major)
cdata.set('PYGOBJECT_MINOR_VERSION', pygobject_version_minor)
cdata.set('PYGOBJECT_MICRO_VERSION', pygobject_version_micro)

configure_file(output : 'config.h', configuration : cdata)

pkgconf = configuration_data()

pkgconf.set('prefix', join_paths(get_option('prefix')))
pkgconf.set('exec_prefix', '${prefix}')
144 145
pkgconf.set('includedir', join_paths('${prefix}', get_option('includedir')))
pkgconf.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
146 147 148 149 150 151 152 153 154 155
pkgconf.set('datadir', '${datarootdir}')
pkgconf.set('VERSION', pygobject_version)

pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))

configure_file(input : 'pygobject-@0@.pc.in'.format(platform_version),
  output : 'pygobject-@0@.pc'.format(platform_version),
  configuration : pkgconf,
  install_dir : pkg_install_dir)

156 157 158 159 160 161
pygobject_dep = declare_dependency(
  include_directories: include_directories('gi'),
  dependencies: [gobject_dep, ffi_dep],
  version: meson.project_version(),
)

162 163 164 165 166 167 168 169
if pygobject_version_minor.is_odd()
  py_version = '@0@.dev0'.format(pygobject_version)
else
  py_version = pygobject_version
endif

pkginfo_conf = configuration_data()
pkginfo_conf.set('VERSION', py_version)
170
configure_file(input : 'PKG-INFO.in',
171 172
  output : 'PyGObject-@0@.egg-info'.format(py_version),
  configuration : pkginfo_conf,
173
  install_dir : python.get_install_dir(pure : false))
174 175 176

subdir('gi')
subdir('pygtkcompat')
Adam Duskett's avatar
Adam Duskett committed
177 178
with_tests = get_option('tests')
if with_tests
179
subdir('tests')
Adam Duskett's avatar
Adam Duskett committed
180
endif