meson.build 3.61 KB
Newer Older
1
project('gnome-multi-writer', 'c',
Richard Hughes's avatar
Richard Hughes committed
2
  version : '3.32.0',
3
  default_options : ['warning_level=1'],
4
  meson_version : '>=0.46.0'
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
)

conf = configuration_data()
conf.set('PACKAGE_VERSION', meson.project_version())

# get suported warning flags
test_args = [
  '-Waggregate-return',
  '-Warray-bounds',
  '-Wcast-align',
  '-Wclobbered',
  '-Wdeclaration-after-statement',
  '-Wempty-body',
  '-Wextra',
  '-Wformat=2',
  '-Wformat-nonliteral',
  '-Wformat-security',
  '-Wformat-signedness',
  '-Wignored-qualifiers',
  '-Wimplicit-function-declaration',
  '-Winit-self',
  '-Winline',
  '-Wmissing-declarations',
  '-Wmissing-format-attribute',
  '-Wmissing-include-dirs',
  '-Wmissing-noreturn',
  '-Wmissing-parameter-type',
  '-Wmissing-prototypes',
  '-Wnested-externs',
  '-Wno-discarded-qualifiers',
  '-Wno-missing-field-initializers',
  '-Wno-strict-aliasing',
  '-Wno-suggest-attribute=format',
  '-Wno-unused-parameter',
Richard Hughes's avatar
Richard Hughes committed
39
  '-Wno-cast-function-type',
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  '-Wold-style-definition',
  '-Woverride-init',
  '-Wpacked',
  '-Wpointer-arith',
  '-Wredundant-decls',
  '-Wreturn-type',
  '-Wshadow',
  '-Wsign-compare',
  '-Wstrict-aliasing',
  '-Wstrict-prototypes',
  '-Wswitch-default',
  '-Wtype-limits',
  '-Wundef',
  '-Wuninitialized',
  '-Wunused-but-set-variable',
  '-Wwrite-strings'
]
cc = meson.get_compiler('c')
foreach arg: test_args
  if cc.has_argument(arg)
    add_project_arguments(arg, language : 'c')
  endif
endforeach

# enable full RELRO where possible
# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
test_link_args = [
  '-Wl,-z,relro',
  '-Wl,-z,now',
]
foreach arg: test_link_args
71 72
  if cc.has_link_argument(arg)
    add_project_link_arguments(arg, language : 'c')
73 74 75
  endif
endforeach

76 77 78 79 80
prefixed_localedir = join_paths(get_option('prefix'), get_option('localedir'))
prefixed_libexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
prefixed_mandir = join_paths(get_option('prefix'), get_option('mandir'))
prefixed_datadir = join_paths(get_option('prefix'), get_option('datadir'))

81 82 83 84 85 86 87 88 89 90 91 92 93
gtk = dependency('gtk+-3.0', version : '>= 3.11.2')
gio = dependency('gio-2.0')
gusb = dependency('gusb', version : '>= 0.2.7')
udisks = dependency('udisks2')
gudev = dependency('gudev-1.0')
libcanberra = dependency('libcanberra-gtk3', version : '>= 0.10')
polkit = dependency('polkit-gobject-1')

gnome = import('gnome')
i18n = import('i18n')

conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set_quoted('VERSION', meson.project_version())
94 95 96
conf.set_quoted('LOCALEDIR', prefixed_localedir)
conf.set_quoted('LIBEXECDIR', prefixed_libexecdir)

97 98
configure_file(
  output : 'config.h',
99
  configuration : conf,
100 101 102 103 104 105 106
)

subdir('src')
subdir('man')
subdir('po')
subdir('data')

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
if meson.version().version_compare('<0.41.0')
  archiver = find_program('git', required : false)
  if archiver.found()
    run_target('dist',
      # git config tar.tar.xz.command "xz -c"
      command: [
        'git', 'archive',
        '--prefix=' + meson.project_name() + '-' + meson.project_version() + '/',
        'HEAD',
        '--format=tar.xz',
        '--output',
        meson.project_name() + '-' + meson.project_version() + '.tar.xz'
      ]
    )
  else
    message('git not found, you will not be able to run `ninja dist`')
  endif
124 125 126 127 128 129 130 131 132 133 134 135 136 137
endif

appstream_util = find_program('appstream-util', required : false)
if appstream_util.found()
  custom_target('NEWS',
    output : 'NEWS',
    input : 'data/appdata/org.gnome.MultiWriter.appdata.xml.in',
    command : [appstream_util, 'appdata-to-news', '@INPUT@'],
    capture : true
  )
endif

# FIXME: remove when https://github.com/mesonbuild/meson/issues/837 fixed
meson.add_install_script('meson_post_install.sh')