-
Notifications
You must be signed in to change notification settings - Fork 2
/
meson.build
91 lines (79 loc) · 2.04 KB
/
meson.build
1
2
3
4
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
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
project(
'canfigger',
'c',
version: '0.3.1999',
meson_version : '>= 0.48.0',
license: 'MIT',
default_options: [
'warning_level=3',
'c_std=c99'
]
)
cc = meson.get_compiler('c')
extra_flags = [
'-fno-common',
'-Wshadow',
'-Wstrict-overflow=5',
'-Wformat-security',
'-Wformat-overflow=2',
'-Wunused-result',
'-Werror=odr',
'-Werror=lto-type-mismatch',
'-Werror=strict-aliasing',
]
add_project_arguments(cc.get_supported_arguments(extra_flags), language: 'c')
# Parse version components
version_components = meson.project_version().split('.')
major_version = version_components[0]
minor_version = version_components[1]
patch_version = version_components[2]
conf = configuration_data()
conf.set('CANFIGGER_VERSION_MAJOR', major_version)
conf.set('CANFIGGER_VERSION_MINOR', minor_version)
conf.set('CANFIGGER_VERSION_PATCH', patch_version)
config_h = configure_file(output : 'config.h', configuration : conf)
src = ('canfigger.c')
buildtarget = library(
meson.project_name(),
src,
version : meson.project_version(),
install: not meson.is_subproject(),
)
# How to use in a superproject and other info
# https://mesonbuild.com/Subprojects.html
canfigger_dep = declare_dependency(
include_directories : include_directories('.'),
link_with : buildtarget
)
if get_option('build_examples')
example = executable(
'example',
'example.c',
dependencies: canfigger_dep,
c_args: '-DSOURCE_DIR="@0@"'.format(meson.current_source_dir())
)
endif
if not meson.is_subproject()
pkg = import('pkgconfig')
pkg.generate(
buildtarget,
description : 'Simple configuration file parser library')
install_headers('canfigger.h')
install_subdir(
join_paths('docs'),
install_dir : join_paths(get_option('docdir'), 'html'),
strip_directory : true
)
install_data(files(
'ChangeLog.txt',
'example.c',
'examplerc',
'LICENSE',
'README.md',
'ReleaseNotes.txt'
),
install_dir : get_option('docdir'))
if get_option('build_tests')
subdir('tests')
endif
endif