meson.build 5.45 KB
Newer Older
1
project('zathura', 'c',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
2
  version: '0.4.6',
3
  meson_version: '>=0.47',
Sebastian Ramacher's avatar
Sebastian Ramacher committed
4
  default_options: ['c_std=c11', 'warning_level=3'],
5 6 7 8 9 10 11 12 13 14 15 16
)

version = meson.project_version()
version_array = version.split('.')

# Rules for so_major and so_minor:
# Before a release perform the following checks against the last release:
# * If a function has been removed or the paramaters of a function have changed
#   bump SOMAJOR and set SOMINOR to 0.
# * If any of the exported datastructures have changed in a incompatible way
#   bump SOMAJOR and set SOMINOR to 0.
# * If a function has been added bump SOMINOR.
17 18
plugin_api_version = '3'
plugin_abi_version = '4'
19 20 21 22 23 24 25 26 27

conf_data = configuration_data()
conf_data.set('ZVMAJOR', version_array[0])
conf_data.set('ZVMINOR', version_array[1])
conf_data.set('ZVREV', version_array[2])
conf_data.set('ZVAPI', plugin_api_version)
conf_data.set('ZVABI', plugin_abi_version)
conf_data.set('version', version)

Sebastian Ramacher's avatar
Sebastian Ramacher committed
28
cc = meson.get_compiler('c')
29 30 31 32 33 34 35 36 37 38

prefix = get_option('prefix')
localedir = get_option('localedir')
datadir = get_option('datadir')
metainfodir = join_paths(datadir, 'metainfo')
desktopdir = join_paths(datadir, 'applications')
dbusinterfacesdir = join_paths(datadir, 'dbus-1', 'interfaces')
plugindir = join_paths(get_option('libdir'), 'zathura')

# required dependencies
39
libm = cc.find_library('m', required: false)
Moritz Lipp's avatar
Moritz Lipp committed
40
girara = dependency('girara-gtk3', version: '>=0.3.3', fallback: ['girara', 'girara_dependency'])
41
glib = dependency('glib-2.0', version: '>=2.50')
42
gio = dependency('gio-unix-2.0', required: host_machine.system() != 'windows')
43 44
gthread = dependency('gthread-2.0', version: '>=2.50')
gmodule = dependency('gmodule-no-export-2.0', version: '>=2.50')
45
gtk3 = dependency('gtk+-3.0', version: '>=3.22')
Sebastian Ramacher's avatar
Sebastian Ramacher committed
46
cairo = dependency('cairo')
47

48
build_dependencies = [libm, girara, glib, gio, gthread, gmodule, gtk3, cairo]
49 50 51 52 53 54 55 56 57 58 59

# defines
defines = [
  '-DGETTEXT_PACKAGE="zathura"',
  '-DLOCALEDIR="@0@"'.format(join_paths(prefix, localedir)),
  '-DZATHURA_PLUGINDIR="@0@"'.format(join_paths(prefix, plugindir)),
  '-D_DEFAULT_SOURCE',
]

# compile flags
flags = [
Sebastian Ramacher's avatar
Sebastian Ramacher committed
60
  '-Werror=implicit-function-declaration',
61 62
  '-Werror=vla',
  '-fvisibility=hidden'
63 64 65 66 67
]
flags = cc.get_supported_arguments(flags)

# optional dependencies
additional_sources = []
68
sqlite = dependency('sqlite3', version: '>=3.6.23', required: get_option('sqlite'))
69
synctex = dependency('synctex', version: '>=1.19', required: get_option('synctex'))
70 71
magic = cc.find_library('magic', required: get_option('magic'))
seccomp = dependency('libseccomp', required: get_option('seccomp'))
72

73
if sqlite.found()
74 75
  build_dependencies += sqlite
  defines += '-DWITH_SQLITE'
76
  additional_sources += files('zathura/database-sqlite.c')
77 78
endif

79
if synctex.found()
80 81
  build_dependencies += synctex
  defines += '-DWITH_SYNCTEX'
82 83
  if synctex.version() < '2.0.0' and synctex.version() >= '1.19.0'
    warning('You are using a synctex version pre-SONAME bump, but post-ABI-break. Please make sure to always run zathura using the correct synctex version.')
84
  endif
85 86
endif

87
if magic.found()
88 89 90 91
  build_dependencies += magic
  defines += '-DWITH_MAGIC'
endif

92
if seccomp.found()
93 94
  build_dependencies += seccomp
  defines += '-DWITH_SECCOMP'
95
  additional_sources += files('zathura/seccomp-filters.c')
96 97
endif

98 99 100
# generate version header file
version_header = configure_file(
  input: 'zathura/version.h.in',
101
  output: 'zathura-version.h',
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
  configuration: conf_data
)
include_directories = [
  include_directories('.')
]

subdir('data')
subdir('po')

# source files
sources = files(
  'zathura/adjustment.c',
  'zathura/bookmarks.c',
  'zathura/callbacks.c',
  'zathura/checked-integer-arithmetic.c',
  'zathura/commands.c',
  'zathura/completion.c',
  'zathura/config.c',
  'zathura/content-type.c',
  'zathura/database.c',
  'zathura/database-plain.c',
  'zathura/dbus-interface.c',
  'zathura/document.c',
  'zathura/file-monitor.c',
  'zathura/file-monitor-glib.c',
127
  'zathura/file-monitor-noop.c',
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
  'zathura/file-monitor-signal.c',
  'zathura/jumplist.c',
  'zathura/links.c',
  'zathura/marks.c',
  'zathura/page.c',
  'zathura/page-widget.c',
  'zathura/plugin.c',
  'zathura/print.c',
  'zathura/render.c',
  'zathura/shortcuts.c',
  'zathura/synctex.c',
  'zathura/types.c',
  'zathura/utils.c',
  'zathura/zathura.c',
)
sources += zathura_resources
sources += additional_sources

# header fiels to install
headers = files(
  'zathura/document.h',
  'zathura/links.h',
  'zathura/macros.h',
  'zathura/page.h',
  'zathura/plugin-api.h',
  'zathura/types.h',
)
headers += version_header

# zathura helper library
libzathura = static_library('zathura',
  sources,
  dependencies: build_dependencies,
  include_directories: include_directories,
  c_args: defines + flags
)

# zathura executable
zathura = executable(
  'zathura',
  files('zathura/main.c'),
  dependencies: build_dependencies + [declare_dependency(link_with: libzathura)],
  install: true,
  include_directories: include_directories,
  c_args: defines + flags,
Sebastian Ramacher's avatar
Sebastian Ramacher committed
173
  export_dynamic: true,
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
  gui_app: true
)
install_headers(headers, subdir: 'zathura')

# pkg-config file
pkg = import('pkgconfig')
pkg.generate(
  name: 'zathura',
  description: 'document viewer - plugin API',
  url: 'https://pwmt.org/projects/zathura',
  version: version,
  requires_private: ['girara-gtk3', 'cairo'],
  variables: [
    'apiversion=@0@'.format(plugin_api_version),
    'abiversion=@0@'.format(plugin_abi_version),
    'plugindir=${libdir}/zathura'
  ]
)

Moritz Lipp's avatar
Moritz Lipp committed
193 194
zathura_dependency = declare_dependency(link_with: zathura, include_directories: include_directories)

195 196
subdir('doc')
subdir('tests')