1# Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
2#
3# This file is part of ZToolkit
4#
5# ZToolkit is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Affero General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# ZToolkit is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with ZToolkit.  If not, see <https://www.gnu.org/licenses/>.
17
18project (
19  'ztoolkit', [ 'c' ],
20  version: '0.1.2',
21  license: 'AGPLv3+',
22  meson_version: '>= 0.43.0',
23  default_options: [
24    'warning_level=2',
25    'buildtype=debug',
26    'c_std=gnu11',
27    ],
28  )
29
30cc = meson.get_compiler ('c')
31
32# detect paths
33prefix = get_option ('prefix')
34libdir = join_paths (prefix, get_option ('libdir'))
35includedir = join_paths (
36  prefix, get_option('includedir'))
37
38# detect os
39os_darwin = false
40os_linux = false
41os_dragonfly = false
42os_windows = false
43
44if host_machine.system() == 'darwin'
45  os_darwin = true
46elif host_machine.system() == 'linux'
47  os_linux = true
48elif host_machine.system() == 'dragonfly'
49  os_dragonfly = true
50elif host_machine.system() == 'windows'
51  os_windows = true
52endif
53
54# dependencies
55deps = [
56  # for drawing
57  dependency('cairo', version: '>=1.0.0'),
58
59  # math functions might be implemented in libm
60  cc.find_library('m', required: false),
61  ]
62
63cdata = configuration_data ()
64if os_linux or os_dragonfly
65  deps += dependency('x11')
66  cdata.set('HAVE_X11', 1)
67elif os_darwin
68  add_languages ('objc')
69  deps += dependency(
70    'appleframeworks',
71    modules: [
72      'foundation',
73      'cocoa',
74      'appkit',
75      ])
76endif
77
78if get_option('enable_rsvg')
79  rsvg_dep = dependency('librsvg-2.0', version: '>=2.14')
80  deps += rsvg_dep
81  cdata.set('HAVE_RSVG', 1)
82  if rsvg_dep.version().version_compare('>=2.46')
83    cdata.set('HAVE_RSVG_2_46', 1)
84  endif
85endif
86
87# create config.h
88config_h = configure_file (
89  output: 'ztoolkit_config.h',
90  configuration: cdata,
91  )
92installable_headers = [ config_h ]
93
94# include dirs
95inc_dirs = [
96  include_directories('.'),
97  include_directories('inc'),
98  include_directories('pugl'),
99  include_directories(
100    join_paths ('pugl', 'pugl')),
101  ]
102
103# cflags
104common_cflags = cc.get_supported_arguments([
105  '-fvisibility=hidden',
106  '-Wformat=2',
107  '-Wno-missing-field-initializers',
108  '-Wno-unused-parameter',
109  '-Wno-sequence-point',
110  '-Wignored-qualifiers',
111  '-Wno-cast-function-type',
112  ])
113strict_cflags = []
114if get_option ('strict_flags')
115  strict_cflags = cc.get_supported_arguments([
116    #'-Werror=cast-qual',
117    '-Werror=clobbered',
118    #'-Werror=conversion',
119    '-Werror=disabled-optimization',
120    '-Werror=double-promotion',
121    #'-Werror=float-equal',
122    '-Werror=logical-op',
123    '-Werror=pointer-arith',
124    #'-Werror=sign-conversion',
125    '-Werror=overlength-strings',
126    '-Werror=stringop-truncation',
127    '-Werror=missing-declarations',
128    #'-Werror=redundant-decls',
129    '-Werror=shadow',
130    '-Werror=undef',
131    '-Werror=unused',
132    '-Werror=strict-aliasing',
133    '-fstrict-aliasing',
134    #'-Werror=strict-overflow',
135    '-Wstrict-overflow=2',
136    '-fstrict-overflow',
137    '-Werror=duplicated-branches',
138    '-Werror=duplicated-cond',
139    '-Werror=null-dereference',
140    '-Werror=init-self',
141    '-Werror=jump-misses-init',
142    '-Werror=missing-prototypes',
143    '-Werror=nested-externs',
144    '-Werror=write-strings',
145    '-Werror=implicit-fallthrough',
146    '-Werror=sign-compare',
147    '-Werror=discarded-qualifiers',
148    '-Werror=float-conversion',
149    '-Werror=implicit-function-declaration',
150    '-Werror=uninitialized',
151    '-Werror=maybe-uninitialized',
152    '-Werror=return-type',
153    '-Werror=int-conversion',
154    '-Werror=format-security',
155    '-Werror=incompatible-pointer-types',
156    '-Werror=implicit-int',
157    '-Werror=multistatement-macros',
158    '-Werror=switch',
159    '-Werror=overflow',
160    '-Werror=array-bounds',
161    '-Werror=enum-compare',
162    '-Werror=misleading-indentation',
163    '-Werror=int-in-bool-context',
164    '-Werror=type-limits',
165    '-Werror=deprecated-declarations',
166    '-Werror=format-extra-args',
167    '-Werror=format',
168    '-Wextra',
169    '-Weverything',
170    ])
171endif
172
173add_project_arguments (
174  common_cflags,
175  language: [ 'c' ]
176  )
177
178subdir('pugl')
179subdir('inc')
180subdir('src')
181subdir('tests')
182
183# this is so that it can be used as a meson
184# subproject
185ztoolkit_dep = declare_dependency (
186  include_directories: inc_dirs,
187  dependencies: deps,
188  link_with: ztoolkit_lib)
189
190if not meson.is_subproject()
191  pkg_mod = import('pkgconfig')
192  pkg_mod.generate(
193    libraries: ztoolkit_lib,
194    version: '0.1.2',
195    name: 'ztoolkit',
196    filebase: 'ztoolkit',
197    description: 'A GUI toolkit for LV2 plugins',
198    )
199endif
200