meson.build 5.08 KB
Newer Older
Emmanuele Bassi's avatar
Emmanuele Bassi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
project(
  'clutter', 'c',
  version: '1.26.3',
  license: 'LGPLv2.1+',
  meson_version: '>= 0.44.1',
  default_options: [
    'buildtype=debugoptimized',
    'c_std=c99',
    'warning_level=1',
  ],
)

version = meson.project_version().split('.')
clutter_major_version = version[0].to_int()
clutter_minor_version = version[1].to_int()
clutter_micro_version = version[2].to_int()

clutter_api_version = '@0@.0'.format(clutter_major_version)
clutter_api_name = '@0@-@1@'.format(meson.project_name(), clutter_api_version)

# soname versioning, compatible with libtool
clutter_so_age = 0
clutter_interface_age = clutter_minor_version.is_even() ? clutter_micro_version : 0
clutter_binary_age = 100 * clutter_minor_version + clutter_micro_version - clutter_interface_age
25 26
clutter_soversion = clutter_so_age
clutter_libversion = '@0@.@1@.@2@'.format(clutter_so_age, clutter_binary_age, clutter_interface_age)
Emmanuele Bassi's avatar
Emmanuele Bassi committed
27 28 29 30 31 32 33 34 35 36 37 38 39 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 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

cc = meson.get_compiler('c')
config_h = configuration_data()

add_project_arguments([ '-D_GNU_SOURCE', '-DHAVE_CONFIG_H' ], language: 'c')

# Paths
clutter_prefix = get_option('prefix')
clutter_libdir = join_paths(clutter_prefix, get_option('libdir'))
clutter_datadir = join_paths(clutter_prefix, get_option('datadir'))
clutter_sysconfdir = get_option('sysconfdir')
clutter_libexecdir = join_paths(clutter_prefix, get_option('libexecdir'))
clutter_includedir = join_paths(clutter_prefix, get_option('includedir'))
clutter_localedir = join_paths(clutter_datadir, 'locale')

# Dependencies
glib_req_version = '>= 2.53.4'
cogl_req_version = '>= 1.21.2'
json_glib_req_version = '>= 0.12.0'
atk_req_version = '>= 2.5.3'
cairo_req_version = '>= 1.14.0'
pango_req_version = '>= 1.30'
gi_req_version = '>= 1.39.0'
gtk_doc_req_version = '>= 1.20'
xcomposite_req_version = '>= 0.4'
gdk_req_version = '>= 3.22.6'
libinput_req_version = '>= 0.19.0'
libudev_req_version = '>= 136'

clutter_deps = [
  dependency('gobject-2.0', version: glib_req_version),
  dependency('gio-2.0'),
  dependency('cogl-1.0', version: cogl_req_version),
  dependency('cogl-path-1.0'),
  dependency('cogl-pango-1.0'),
  dependency('cairo-gobject', version: cairo_req_version),
  dependency('atk', version: atk_req_version),
  dependency('json-glib-1.0', version: json_glib_req_version),
]

mathlib_dep = cc.find_library('m', required: false)
clutter_deps += mathlib_dep

# Linker flags
common_ldflags = []
if host_machine.system() == 'linux' and cc.get_id() == 'gcc'
  common_ldflags += [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
elif host_machine.system() == 'darwin'
  common_ldflags += [ '-compatibility_version 1', '-current_version 1.0' ]
endif

# Detect and set symbol visibility
if get_option('default_library') != 'static'
  if host_machine.system() == 'windows'
    config_h.set('DLL_EXPORT', true)
    config_h.set('_CLUTTER_EXTERN', '__declspec(dllexport) extern')
    if cc.get_id() != 'msvc'
      add_project_arguments(['-fvisibility=hidden'], language: 'c')
    endif
  else
    config_h.set('_CLUTTER_EXTERN', '__attribute__((visibility("default"))) extern')
    add_project_arguments(['-fvisibility=hidden'], language: 'c')
  endif
endif

# Windowing system backends
all_backends = [
  'gdk',
  'x11',
  'wayland',
  'win32',
  'quartz',
  'cogl',
100
  'eglnative',
Emmanuele Bassi's avatar
Emmanuele Bassi committed
101 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 127 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 173 174
]

system_backends = []
if host_machine.system() == 'linux'
  system_backends += [ 'gdk', 'x11', 'wayland', ]
elif host_machine.system() == 'windows'
  system_backends += 'win32'
elif host_machine.system() == 'darwin'
  system_backends += 'quartz'
endif

requested_backends = get_option('backends').split(',')
if requested_backends.contains('system')
  enabled_backends = system_backends
elif requested_backends.contains('all')
  enabled_backends = all_backends
else
  enabled_backends = requested_backends
endif

all_drivers = ['*']
requested_drivers = get_option('drivers').split(',')
if requested_drivers.contains('all')
  enabled_drivers = all_drivers
else
  enabled_drivers = requested_drivers
endif

config_h.set('COGL_ENABLE_EXPERIMENTAL_2_0_API', 1)
config_h.set_quoted('CLUTTER_DRIVERS', enabled_drivers)
config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())

root_inc = include_directories('.')

gnome = import('gnome')
pkgconf = import('pkgconfig')

subdir('clutter')
subdir('po')

if get_option('build_tests')
  subdir('tests')
endif

if get_option('build_examples')
  subdir('examples')
endif

if get_option('documentation')
  subdir('doc')
endif

summary = [
  'Clutter',
  '----------------',
  '        version: @0@'.format(meson.project_version()),
  '',
  '         prefix: @0@'.format(clutter_prefix),
  '         libdir: @0@'.format(clutter_libdir),
  '     includedir: @0@'.format(clutter_includedir),
  '        datadir: @0@'.format(clutter_datadir),
  '     libexecdir: @0@'.format(clutter_libexecdir),
  '',
  '       backends: @0@'.format(' '.join(enabled_backends)),
  '     GL drivers: @0@'.format(get_option('drivers')),
  '',
  '  documentation: @0@'.format(get_option('documentation')),
  '  introspection: @0@'.format(get_option('introspection')),
  '       examples: @0@'.format(get_option('build_examples')),
  '          tests: @0@'.format(get_option('build_tests')),
  '',
]

message('\n'.join(summary))